Skip to content

Commit

Permalink
improved the logs that the connectum scraper puts out
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed May 9, 2024
1 parent 0d3e59c commit e168b3e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 7 additions & 4 deletions server/main-api/src/calendar/connectum.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::time::Duration;
use std::time::{Duration, Instant};
use std::{env, io};

use cached::instant::Instant;
use chrono::{DateTime, Utc};
use log::{debug, error, warn};
use oauth2::basic::{BasicClient, BasicTokenResponse};
Expand Down Expand Up @@ -54,7 +53,7 @@ impl APIRequestor {
.json()
.await?;
debug!(
"finished fetching for {id}: {cnt} calendar events in {elapsed:?}",
"finished fetching for {cnt} calendar events of {id} in {elapsed:?}",
cnt = events.len(),
elapsed = start.elapsed()
);
Expand Down Expand Up @@ -98,6 +97,7 @@ impl APIRequestor {
last_calendar_scrape_at: &DateTime<Utc>,
id: &str,
) -> Result<(), crate::BoxedError> {
let start = Instant::now();
// insert into db
let mut tx = self.pool.begin().await?;
if let Err(e) = self.delete_events(&mut tx, id).await {
Expand Down Expand Up @@ -130,7 +130,10 @@ impl APIRequestor {
return Err(e.into());
}
tx.commit().await?;
debug!("finished inserting into the db for {id}");
debug!(
"finished inserting into the db for {id} in {elapsed:?}",
elapsed = start.elapsed()
);
Ok(())
}

Expand Down
3 changes: 1 addition & 2 deletions server/main-api/src/calendar/refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ LIMIT 20"#)
}
};
let len = ids.len();
debug!("Downloading {len} calendars");
for LocationKey { key } in ids {
if let Err(e) = api.refresh(&key).await {
error!("Could not download calendar for {key} because {e:?}");
}
}
debug!(
"Downloading {len} calendars took {elapsed:?}",
"Downloaded {len} room-calendars took {elapsed:?}",
elapsed = start.elapsed()
);
interval.tick().await;
Expand Down

0 comments on commit e168b3e

Please sign in to comment.