From 8826e7a5a0bd74c59e6051cd30315fe98dcfb52a Mon Sep 17 00:00:00 2001 From: Jaguar0625 Date: Mon, 20 May 2024 14:05:52 -0400 Subject: [PATCH] [history]: summarizer fails when there are no records for period problem: date is only calculated when there are matching records for period when there are no matching records, there is no date and sorting fails solution: check if date exists before accessing during sort --- history/summarizer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/history/summarizer.py b/history/summarizer.py index 269dc1a..3970968 100644 --- a/history/summarizer.py +++ b/history/summarizer.py @@ -71,7 +71,7 @@ def save(self, filename): csv_writer = csv.DictWriter(outfile, field_names) csv_writer.writerow(dict(zip(field_names, field_names))) - for row in sorted(self.rows, key=lambda row: row['date']): + for row in sorted(self.rows, key=lambda row: (row['date'] is not None, row['date'])): csv_writer.writerow(row)