Skip to content

Commit a80b7df

Browse files
committed
feat: Create weekly.py
1 parent 6c668b4 commit a80b7df

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

ghgql/weekly.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import lib
2+
3+
4+
QUERY_PATH = 'queries/contributions/weekly.gql'
5+
6+
7+
def process_weeks(value):
8+
year_of_weeks = value['contributionCalendar']['weeks']
9+
10+
out_days = {}
11+
for week in year_of_weeks:
12+
for day in week['contributionDays']:
13+
date = day['date']
14+
count = day['contributionCount']
15+
out_days[date] = count
16+
17+
return out_days
18+
19+
20+
def process():
21+
resp_data = lib.query_by_filename(QUERY_PATH)
22+
23+
user_years = resp_data['viewer']
24+
# We don't actually care about the year keys, as the dates are in granualar data.
25+
contributions_by_year = [process_weeks(v) for v in user_years.values()]
26+
all_contributions = {}
27+
for year in contributions_by_year:
28+
all_contributions.update(**year)
29+
30+
return all_contributions
31+
32+
33+
def main():
34+
all_contributions = process()
35+
for k in sorted(all_contributions):
36+
print(k, all_contributions[k])
37+
38+
39+
if __name__ == '__main__':
40+
main()

0 commit comments

Comments
 (0)