From d1066e7a26d8da0d1ed2e15997a485879e46611d Mon Sep 17 00:00:00 2001 From: hmj6502 Date: Sun, 28 Dec 2025 15:38:17 +0000 Subject: stop/start & rest bank complete on stopwatch - cumulative time wasn't too bad to add actually - one id per session added - change formatting.py so that it only counts time that is of type 'focus' as time to put on chart - add pie chart and time in minutes rather than seconds to display.py --- main.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'main.py') diff --git a/main.py b/main.py index cbdc9e3..1c3846e 100755 --- a/main.py +++ b/main.py @@ -11,7 +11,7 @@ import formatting as f print("welcome to lock-n-log, the best way to organise and analyse your focus time!") -ratio = 1 # default for now +ratio = 1/3 # default for now sesh_type = "focus" print("tag for session? ", end="", flush=True) @@ -41,11 +41,12 @@ else: input() sesh_list = [] -elapsed, rest, start = timers.timer(timer_length, ratio, 0) +elapsed_total = 0 +elapsed, rest, start = timers.timer(timer_length, ratio) +session_id = hashlib.sha256(str(start).encode('utf8')).hexdigest() while rest > 0: -# print("\nneed to rest " + str(int(rest))) session = OrderedDict() - session["id"] = hashlib.sha256(str(start).encode('utf8')).hexdigest() + session["id"] = session_id session["date"] = start.strftime("%Y-%m-%d") session["start"] = start.strftime("%H:%M:%S") session["elapsed"] = int(elapsed) @@ -54,6 +55,7 @@ while rest > 0: session["timer"] = timer session["ratio"] = ratio sesh_list.append(session) + elapsed_total += elapsed sesh_type = "rest" elapsed, dontcare, start = timers.timer(rest, 0, 0) @@ -62,7 +64,7 @@ while rest > 0: else: rest -= elapsed session = OrderedDict() - session["id"] = hashlib.sha256(str(start).encode('utf8')).hexdigest() + session["id"] = session_id session["date"] = start.strftime("%Y-%m-%d") session["start"] = start.strftime("%H:%M:%S") session["elapsed"] = int(elapsed) @@ -73,13 +75,13 @@ while rest > 0: sesh_list.append(session) sesh_type = "focus" - elapsed, rest, start = timers.timer(0, ratio, rest) + elapsed, rest, start = timers.timer(0, ratio, rest, elapsed_total) if rest == 0: break print("\nfocus session finished!\nlogging...") session = OrderedDict() -session["id"] = hashlib.sha256(str(start).encode('utf8')).hexdigest() +session["id"] = session_id session["date"] = start.strftime("%Y-%m-%d") session["start"] = start.strftime("%H:%M:%S") session["elapsed"] = int(elapsed) @@ -90,6 +92,5 @@ session["ratio"] = ratio sesh_list.append(session) for session in sesh_list: - print(session) - -#f.sesh_to_log(session, "main.csv") +# print(session) + f.sesh_to_log(session, "main.csv") -- cgit v1.2.3