patrickvonplaten commited on
Commit
db33e16
1 Parent(s): 699a234
Files changed (1) hide show
  1. plot_access_requests.py +43 -0
plot_access_requests.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ import json
3
+ import sys
4
+ import numpy as np
5
+ from collections import Counter
6
+ import matplotlib as mpl
7
+ import matplotlib.pyplot as plt
8
+
9
+ files = sys.argv[1:]
10
+
11
+ def retrieve_day_to_num_signups(file):
12
+ with open(file, "r") as f:
13
+ json_file = json.load(f)
14
+
15
+ list_of_days = [x["time"].split("T")[0] for x in json_file]
16
+
17
+ return Counter(list_of_days)
18
+
19
+
20
+ files = {f.split()[0].split("user-access-report-")[-1]: f for f in files}
21
+ counters = {file: retrieve_day_to_num_signups(path) for file, path in files.items()}
22
+ total_counters = {file: np.cumsum(list(counters[file].values())) for file in files.keys()}
23
+
24
+ max_size = max([c.shape[0] for c in list(total_counters.values())])
25
+ time_axis = np.arange(0, max_size)
26
+
27
+ plot_counters = {}
28
+ for k, v in total_counters.items():
29
+ plot_counters[k] = np.zeros(max_size, dtype=np.int32)
30
+ if not v.shape[0] == max_size:
31
+ plot_counters[k][-v.shape[0]:] = v
32
+ else:
33
+ plot_counters[k] = v
34
+
35
+ fig, ax = plt.subplots()
36
+ for file in files.keys():
37
+ ax.plot(time_axis, plot_counters[file], label=file)
38
+
39
+ ax.set_xlabel("day since launch (on 23/08)")
40
+ ax.set_ylabel("number of requsets")
41
+ ax.set_title("Acces requests comparision")
42
+ ax.legend()
43
+ plt.savefig("access_requests.png")