Add whatnext (intention) to CSV log now that we have sophisticated analysis capabilities

This commit is contained in:
mlncn 2021-05-02 12:16:52 -04:00
parent 9a8be46f8a
commit 445aa1d8c5

View file

@ -74,15 +74,15 @@ def log_step(text, utc_start, end_section=False):
timelog.write('\n\n') timelog.write('\n\n')
def record_task(whatdid, start, end=None): def record_task(whatnext, whatdid, start, end=None):
""" Record completed pomodoro to CSV """ Record completed pomodoro to CSV
""" """
if end is None: if end is None:
end = datetime.now(pytz.utc) end = datetime.now(pytz.utc)
with open('timelog.csv', 'a', newline='') as csvfile: with open('log/timelog.csv', 'a', newline='') as csvfile:
# TODO make first line started, recorded, description # TODO make first line started, recorded, description, intention
timewriter = csv.writer(csvfile) timewriter = csv.writer(csvfile)
timewriter.writerow([start, end, whatdid]) timewriter.writerow([start, end, whatdid, whatnext])
def str_minutes(time_diff): def str_minutes(time_diff):
""" Return at least whole seconds from a time difference """ Return at least whole seconds from a time difference
@ -111,7 +111,7 @@ def main():
if not QUIET: if not QUIET:
playsound('res/timesup.aac') playsound('res/timesup.aac')
whatdid = pomodoro_prompt_report(whatnext) whatdid = pomodoro_prompt_report(whatnext)
record_task(whatdid, start) record_task(whatnext, whatdid, start)
log_step('Completed pomodoro: ' + whatdid, start, True) log_step('Completed pomodoro: ' + whatdid, start, True)
print('Worked on: ' + whatdid) print('Worked on: ' + whatdid)
@ -136,13 +136,13 @@ def main():
choice = input('[y]/n: ').strip() choice = input('[y]/n: ').strip()
if choice.lower() in ('y', 'yes', ''): if choice.lower() in ('y', 'yes', ''):
whatdid = pomodoro_prompt_report(whatnext) whatdid = pomodoro_prompt_report(whatnext)
record_task(whatdid, start) record_task(whatnext, whatdid, start)
log_step('Incomplete (' + time_spent_str + ') pomodoro: ' + whatdid, start, True) log_step('Incomplete (' + time_spent_str + ') pomodoro: ' + whatdid, start, True)
quit_prompt() quit_prompt()
else: else:
print('What did you break?') print('What did you break?')
# If we somehow end up here, try a last-ditch effort to save. # If we somehow end up here, try a last-ditch effort to save.
record_task('Incomplete, interrupted task:' + whatnext, start) record_task(whatnext, 'Incomplete, interrupted task:' + whatnext, start)
log_step('Incomplete, interrupted task:' + whatnext, start, True) log_step('Incomplete, interrupted task:' + whatnext, start, True)