-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstat_gitlab_fetches.py
More file actions
31 lines (24 loc) · 891 Bytes
/
stat_gitlab_fetches.py
File metadata and controls
31 lines (24 loc) · 891 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
27
28
29
30
31
# pylint: disable=missing-function-docstring
import os
from pprint import pprint
from stat_git_downloads import (
get_current_gitlab_stat,
get_archive_stat,
save_stats,
public_stats,
merge_two_lists_of_dicts_by_key_condition,
)
GL_COUNT_CLONES_BADGE = os.environ.get('GL_COUNT_CLONES_BADGE')
LOG_FILE = 'gl_fetches.json'
BADGE_SVG = 'gl_fetches.svg'
def sum_clones_stats(stats) -> int:
print('sum_clones_stats')
summary = sum(s['count'] for s in stats)
pprint(summary)
return summary
CURRENT = get_current_gitlab_stat()['fetches']['days']
ARCHIVE = get_archive_stat(GL_COUNT_CLONES_BADGE)
MERGED = merge_two_lists_of_dicts_by_key_condition(CURRENT, ARCHIVE, key1='date', key2='count')
SUMMARY: int = sum_clones_stats(MERGED)
save_stats(MERGED, LOG_FILE)
public_stats(SUMMARY, 'downloads/gitlab/fetches', BADGE_SVG, GL_COUNT_CLONES_BADGE, LOG_FILE)