Keep a version of harvest data around with same keys other stuff has, before renaming columns

This commit is contained in:
benjamin melançon 2021-06-02 08:56:01 -04:00
parent e9021e4ed9
commit aa05dc5734

View file

@ -168,20 +168,22 @@ latest = tl.recorded.max()
# Separate Harvest from non-Harvest projects, and also filter out any blank
# projects, but save those too for a CSV of the excluded items.
harvest = tl[tl.project.isin(harvest_project_names.keys())]
hrvst = tl[tl.project.isin(harvest_project_names.keys())]
other = tl[tl.project.isin(other_project_names.keys())]
unknown = tl[~tl.project.isin(replacement_project_names.keys())]
harvest.rename(columns = {'date': 'Date', 'project': 'Project', 'description': 'Note'}, inplace = True)
harvest = hrvst.rename(columns = {'date': 'Date', 'project': 'Project', 'subproject': 'Task', 'description': 'Note'})
harvest["Hours"] = harvest["time"]/60
harvest["First name"] = "Benjamin"
harvest["Last name"] = "Melançon"
harvest.drop(columns = ['started', 'recorded', 'time'], inplace=True)
if not debug:
harvest.to_csv('harvest-timesheets.csv', index=False)
other.to_csv('not-harvest.csv', index=False)
settings.pomodoro_latest_recorded(latest)
else:
harvest_grouped = harvest.groupby("project").agg({"time": "sum"})["time"]/60
hrvst_grouped = hrvst.groupby("project").agg({"time": "sum"})["time"]/60
other_grouped = other.groupby("project").agg({"time": "sum"})["time"]/60
unknown_grouped = unknown.groupby("project").agg({"time": "sum"})["time"]/60
print("We do not write to the harvest-ready.csv nor update the latest recorded setting when run interactively in the python shell.")