summaryrefslogtreecommitdiff
path: root/formatting.py
diff options
context:
space:
mode:
authorhmj6502 <hashim@hmj6502.com>2025-12-18 21:54:49 +0000
committerhmj6502 <hashim@hmj6502.com>2025-12-18 21:54:49 +0000
commitb7f285f2b866366cff49d49ccfb49a40c62cb0e3 (patch)
tree43e6cd6d143add79fe3409cdcb69620ea880dc88 /formatting.py
parent81f6bcf7d7a62b6d920e17a2d30512c260d6c586 (diff)
downloadlock-n-log-b7f285f2b866366cff49d49ccfb49a40c62cb0e3.tar.gz
lock-n-log-b7f285f2b866366cff49d49ccfb49a40c62cb0e3.tar.bz2
lock-n-log-b7f285f2b866366cff49d49ccfb49a40c62cb0e3.zip
add basic rendering
display each day as a seperate svg; each a bar chart of tags of that day
Diffstat (limited to 'formatting.py')
-rw-r--r--formatting.py22
1 files changed, 22 insertions, 0 deletions
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