From d0ec4ee2cdf99b9ff71ea02986dcc5a10e8496ef Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Sun, 1 Sep 2024 13:23:48 +0200 Subject: [PATCH] feat: make the log output less spammy --- server/src/calendar/mod.rs | 4 ++-- server/src/calendar/models.rs | 22 ++++++++++++++++++---- server/src/search/search_executor/query.rs | 8 ++++---- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/server/src/calendar/mod.rs b/server/src/calendar/mod.rs index a230a799f..38e61b8c3 100644 --- a/server/src/calendar/mod.rs +++ b/server/src/calendar/mod.rs @@ -113,7 +113,7 @@ async fn get_locations( } } -#[tracing::instrument(skip(pool),ret(level = tracing::Level::TRACE))] +#[tracing::instrument(skip(pool))] async fn get_from_db( pool: &PgPool, locations: &[CalendarLocation], @@ -130,7 +130,7 @@ async fn get_from_db( location.key.clone(), LocationEvents { location: location.clone(), - events, + events: events.into(), }, ); } diff --git a/server/src/calendar/models.rs b/server/src/calendar/models.rs index 37d8e911f..c87cfe458 100644 --- a/server/src/calendar/models.rs +++ b/server/src/calendar/models.rs @@ -1,8 +1,9 @@ use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; -use std::fmt::Display; +use std::fmt::{Display, Debug, Formatter}; +use crate::limited::vec::LimitedVec; -#[derive(Serialize, Deserialize, Clone, Debug)] +#[derive(Serialize, Deserialize, Clone)] pub(super) struct CalendarLocation { pub key: String, pub name: String, @@ -11,9 +12,22 @@ pub(super) struct CalendarLocation { pub type_common_name: String, pub r#type: String, } -#[derive(Serialize, Deserialize, Clone, Debug)] + +impl Debug for CalendarLocation{ + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + let mut base= f.debug_struct("CalendarLocation"); + base.field("building", &self.key) + .field("name", &self.name); + if let Some(from)=&self.last_calendar_scrape_at{ + base.field("from", from); + } + base.finish() + } +} + +#[derive(Serialize, Deserialize, Clone)] pub(super) struct LocationEvents { - pub(super) events: Vec, + pub(super) events: LimitedVec, pub(super) location: CalendarLocation, } diff --git a/server/src/search/search_executor/query.rs b/server/src/search/search_executor/query.rs index 1b1130073..e205eb134 100644 --- a/server/src/search/search_executor/query.rs +++ b/server/src/search/search_executor/query.rs @@ -26,10 +26,10 @@ pub(super) struct MSHit { } impl Debug for MSHit { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - let mut base = f.debug_struct("MSHit"); - base.field("id", &self.id); - base.field("name", &self.name); - base.finish() + f.debug_struct("MSHit") + .field("id", &self.id) + .field("name", &self.name) + .finish() } }