Skip to content

Commit

Permalink
fix: saving only valid dates when archiving (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
sagojez authored Oct 31, 2024
1 parent aa14306 commit 0be3b9a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions integrationos-archiver/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ async fn dump(
let max_end = Utc::now() - CDuration::days(config.min_date_days);
let end = (start + CDuration::days(config.chunk_to_process_in_days)).min(max_end);

if start.timestamp_millis() >= end.timestamp_millis() {
// If the very first event is after the end time, exit
tracing::warn!("No events to process, exiting");
return Ok(());
}

archives
.create_one(&Event::DateChosen(DateChosen::new(
started.reference(),
Expand All @@ -196,12 +202,6 @@ async fn dump(
)))
.await?;

if start.timestamp_millis() >= end.timestamp_millis() {
// If the very first event is after the end time, exit
tracing::warn!("No events to process, exiting");
return Ok(());
}

tracing::info!("Start date: {}, End date: {}", start, end);

let chunks = start.divide_by_stream(CDuration::minutes(config.chunk_size_minutes), end); // Chunk size is 20 minutes by default
Expand Down

0 comments on commit 0be3b9a

Please sign in to comment.