-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstat_github_uniques.py
More file actions
26 lines (19 loc) · 880 Bytes
/
stat_github_uniques.py
File metadata and controls
26 lines (19 loc) · 880 Bytes
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
# pylint: disable=missing-function-docstring
import os
from pprint import pprint
from stat_git_downloads import get_current_github_stat, get_archive_stat, save_stats, \
public_stats, merge_two_lists_of_dicts_by_key_condition
GH_UNIQUE_CLONES_BADGE = os.environ.get('GH_UNIQUE_CLONES_BADGE')
LOG_FILE = 'gh_unique_clones.json'
BADGE_SVG = 'gh_unique_clones.svg'
def sum_uniques_stats(stats) -> int:
print('sum_uniques_stats')
summary = sum(s['uniques'] for s in stats)
pprint(summary)
return summary
CURRENT = get_current_github_stat()['clones']
ARCHIVE = get_archive_stat(GH_UNIQUE_CLONES_BADGE)
MERGED = merge_two_lists_of_dicts_by_key_condition(CURRENT, ARCHIVE, 'timestamp', 'uniques')
SUMMARY: int = sum_uniques_stats(MERGED)
save_stats(MERGED, LOG_FILE)
public_stats(SUMMARY, 'downloads/github/unique', BADGE_SVG, GH_UNIQUE_CLONES_BADGE, LOG_FILE)