2
2
3
3
4
4
def process_user_data (json_file , top_pages , this_year , map , md_file ):
5
+ """
6
+ Function for writing portal/metrics.md from saved files output by get-metrics.py
7
+ """
5
8
with open (json_file , 'r' ) as f :
6
9
user_data = json .load (f )
7
10
@@ -12,6 +15,7 @@ def process_user_data(json_file, top_pages, this_year, map, md_file):
12
15
user_data .pop ('Now' )
13
16
f .write ('\n \n ' )
14
17
18
+ # Markdown table
15
19
headers = '| Project | Users |'
16
20
separator = '| ' + ' | ' .join (['-----' ] * 2 ) + ' |'
17
21
rows = []
@@ -21,6 +25,7 @@ def process_user_data(json_file, top_pages, this_year, map, md_file):
21
25
f .write (table )
22
26
f .write ('\n \n ' )
23
27
28
+ # Add plots
24
29
f .write (f'\n \n ' )
25
30
f .write (f'\n \n ' )
26
31
f .write (f'\n \n ' )
@@ -29,9 +34,12 @@ def process_user_data(json_file, top_pages, this_year, map, md_file):
29
34
30
35
31
36
if __name__ == '__main__' :
32
- json_file = 'portal/metrics/user_metrics.json'
37
+ json_file = 'portal/metrics/user_metrics.json' # Accessed from root repository
38
+
39
+ # HTML is built from within `portal/` directory, so paths differ from json file.
33
40
top_pages = 'metrics/toppages.png'
34
41
this_year = 'metrics/thisyear.png'
35
42
map = 'metrics/bycountry.png'
36
- md_file = 'portal/metrics.md'
43
+
44
+ md_file = 'portal/metrics.md' # Written from root repository
37
45
process_user_data (json_file , top_pages , this_year , map , md_file )
0 commit comments