From 1b233fbc84f8d2dab88f9d75df002e44ca4fc5db Mon Sep 17 00:00:00 2001 From: Nathaniel Cook Date: Tue, 8 Oct 2024 11:16:18 -0600 Subject: [PATCH] fix: only write out error counts on errors --- event-svc/src/event/migration.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/event-svc/src/event/migration.rs b/event-svc/src/event/migration.rs index 9bf46e75..4371248f 100644 --- a/event-svc/src/event/migration.rs +++ b/event-svc/src/event/migration.rs @@ -131,16 +131,18 @@ impl<'a, S: BlockStore> Migrator<'a, S> { tile_doc_count = self.tile_doc_count, "migration finished" ); - // Write out model error counts - const CSV_FILE_PATH: &str = "model_error_counts.csv"; - let mut model_csv = File::create(CSV_FILE_PATH).await?; - model_csv.write_all(b"model,count\n").await?; - for (model, count) in self.model_error_counts { - model_csv - .write_all(format!("{model},{count}\n").as_bytes()) - .await?; + if !self.model_error_counts.is_empty() { + // Write out model error counts + const CSV_FILE_PATH: &str = "model_error_counts.csv"; + let mut model_csv = File::create(CSV_FILE_PATH).await?; + model_csv.write_all(b"model,count\n").await?; + for (model, count) in self.model_error_counts { + model_csv + .write_all(format!("{model},{count}\n").as_bytes()) + .await?; + } + info!(path = CSV_FILE_PATH, "wrote error counts by model"); } - info!(path = CSV_FILE_PATH, "wrote error counts by model"); Ok(()) } // Decodes the block and if it is a Ceramic event, it and related blocks are constructed into an