Fix error when caching zero results

This commit is contained in:
Joshua Coles 2024-02-04 17:30:47 +00:00
parent d5dfb47aea
commit 5d9184df32

View File

@ -57,6 +57,13 @@ pub async fn report(
async fn cache_report(db: &DatabaseConnection, models: &Vec<ReportEntry>) -> Result<()> {
let models = models.iter().flat_map(|entry| entry.as_models());
let models = models.collect::<Vec<_>>();
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())