File size: 1,246 Bytes
db33e16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
import json
import sys
import numpy as np
from collections import Counter
import matplotlib as mpl
import matplotlib.pyplot as plt

files = sys.argv[1:]

def retrieve_day_to_num_signups(file):
    with open(file, "r") as f:
        json_file = json.load(f)

    list_of_days = [x["time"].split("T")[0] for x in json_file]

    return Counter(list_of_days)


files = {f.split()[0].split("user-access-report-")[-1]: f for f in files}
counters = {file: retrieve_day_to_num_signups(path) for file, path in files.items()}
total_counters = {file: np.cumsum(list(counters[file].values())) for file in files.keys()}

max_size = max([c.shape[0] for c in list(total_counters.values())])
time_axis = np.arange(0, max_size)

plot_counters = {}
for k, v in total_counters.items():
    plot_counters[k] = np.zeros(max_size, dtype=np.int32)
    if not v.shape[0] == max_size:
        plot_counters[k][-v.shape[0]:] = v
    else:
        plot_counters[k] = v

fig, ax = plt.subplots()
for file in files.keys():
    ax.plot(time_axis, plot_counters[file], label=file)

ax.set_xlabel("day since launch (on 23/08)")
ax.set_ylabel("number of requsets")
ax.set_title("Acces requests comparision")
ax.legend()
plt.savefig("access_requests.png")