~dricottone/fmg-timesheets

ref: 6899c67fa4f55e9d7a82f6b2cd780bc43185f3fc fmg-timesheets/analysis/totals.py -rw-r--r-- 971 bytes
6899c67fDominic Ricottone With data scraping complete, moving on to analysis 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python3

def totals(timesheets):
    projects = {}

    for timesheet in timesheets:
        for entry in timesheet:
            key = entry.project
            if entry.time_code in ("HOL", "OTU", "VAC", "OPL", ):
                key = entry.time_code

            if key not in projects.keys():
                projects[key] = {}
                projects[key]["name"] = entry.label
                projects[key]["hours"] = 0

            for hours in entry.data.values():
                projects[key]["hours"] += hours

    for project, data in projects.items():
        print(f"{project:20} {data['name']:100} {data['hours']}")

def total_ocps2020(timesheets):
    total = 0
    for timesheet in timesheets:
        for entry in timesheet:
            if entry.project == "20032.001.20.005":
                for date, hours in entry.data.items():
                    total += hours
                break
    print(f"{total} hours spent on OCPS 2020")