Open OndrejVicar opened 4 years ago
This is an often needed view which we don't have.
We want to see the table Month, Project, Hours.
Month, Project, Hours
I was able to extract it with following code:
projects = [ "project1", "project2", ] # nice for console for month in range(1, 10): print("Měsíc " + str(month) + ":") for project in projects: list = ProjectSeparation.objects.filter(session__swipe__datetime__year=2020, session__swipe__datetime__month=month, project__name=project).values('id', 'time_spend') dict = { x['id']:x['time_spend'] for x in list} hours = sum(dict.values(), datetime.timedelta()).total_seconds() / 3600 if (hours > 0): print(" " + project + ": " + str(hours)) # csv for month in range(1, 10): for project in projects: list = ProjectSeparation.objects.filter(session__swipe__datetime__year=2020, session__swipe__datetime__month=month, project__name=project).values('id', 'time_spend') dict = { x['id']:x['time_spend'] for x in list} hours = sum(dict.values(), datetime.timedelta()).total_seconds() / 3600 if (hours > 0): print(str(month), end=";") print(project, end=";") print(hours, end=";") print("")
THE output CSV spreadsheet is on my gdrive.
This is an often needed view which we don't have.
We want to see the table
Month, Project, Hours
.I was able to extract it with following code:
THE output CSV spreadsheet is on my gdrive.