Finish up filtering of pre-last-recorded stuff

This commit is contained in:
mlncn 2021-05-03 00:01:59 -04:00
parent 0077a27da0
commit 01c8670eb6

View file

@ -28,6 +28,11 @@ timelog = timelog.explode("description").reset_index()
timelog["started"] = pd.to_datetime(timelog["started"]).dt.tz_convert("US/Eastern")
timelog["recorded"] = pd.to_datetime(timelog["recorded"]).dt.tz_convert("US/Eastern")
latest_recorded = settings.pomodoro_latest_recorded()
if latest_recorded:
timelog = timelog.query("recorded>" + latest_recorded)
timelog["time"] = 30
# A pomodoro started before 3am Eastern time is considered to be a continuation
# of the day before, so we are, effectively, on West Coast time for determining
@ -89,6 +94,8 @@ for preferred, alternatives in replacement_project_names.items():
# The fillna is essential or we drop entries with blank ('None') projects.
tl = timelog.groupby(["date", timelog.project.fillna(""), "description"]).agg({"time": 'sum', "started": 'min', "recorded": 'max'}).reset_index()
tl.to_csv('harvest-ready.csv', index = False)
settings.pomodoro_latest_recorded(tl.recorded.max())
if hasattr(sys, 'ps1'):
tl.to_csv('harvest-ready.csv', index=False)
settings.pomodoro_latest_recorded(tl.recorded.max())
else:
print("We do not write to the harvest-ready.csv nor update the latest recorded setting when run interactively in the python shell.")