|
|
|
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") |
|
|