diff --git a/src/main.rs b/src/main.rs index f69ce60..eaa4c73 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,6 +57,13 @@ pub async fn report( async fn cache_report(db: &DatabaseConnection, models: &Vec) -> Result<()> { let models = models.iter().flat_map(|entry| entry.as_models()); + let models = models.collect::>(); + debug!("Caching report entries: {:?}", models); + + // TODO: Why is this needed? + if models.is_empty() { + return Ok(()); + } TimeEntry::insert_many(models) .on_conflict(ReportEntry::grafting_conflict_statement())