From 5d9184df320d7c9bb33631423d752e3611b05645 Mon Sep 17 00:00:00 2001 From: Joshua Coles Date: Sun, 4 Feb 2024 17:30:47 +0000 Subject: [PATCH] Fix error when caching zero results --- src/main.rs | 7 +++++++ 1 file changed, 7 insertions(+) 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())