From b7f285f2b866366cff49d49ccfb49a40c62cb0e3 Mon Sep 17 00:00:00 2001 From: hmj6502 Date: Thu, 18 Dec 2025 21:54:49 +0000 Subject: add basic rendering display each day as a seperate svg; each a bar chart of tags of that day --- formatting.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'formatting.py') diff --git a/formatting.py b/formatting.py index a7c7ed7..5002ee9 100644 --- a/formatting.py +++ b/formatting.py @@ -22,3 +22,25 @@ def sess_to_log(session, filename): if logmode == 'w': writer.writeheader() writer.writerow(session) + +def per_tag_per_day(file): + """returns list of dicts, each has date, tag and time spent per tag""" + reader = csv.DictReader(file) + + rows = [] # need to make into list to transverse backwards + for row in reader: + rows.append(row) + +# list of dicts; each dict is tag: time_spent + day_times = [] + cur = -1 + for i in range(len(rows)): + date = rows[i]['date'] + tag = rows[i]['tag'] + if i > 0 and date == rows[i-1]['date']: + day_times[cur][tag] = day_times[cur].get(tag, 0) + int(rows[i]['elapsed']) + else: + cur += 1 + day_times.append({"date": date, tag: int(rows[i]['elapsed'])}) + + return day_times -- cgit v1.2.3