Skip to content

Commit ccabdc3

Browse files
committed
chore(script): allow saving json if required for further analysis
1 parent dae4bf9 commit ccabdc3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

scripts/get-user-metrics.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,23 @@
1515
import logging
1616
import matplotlib
1717
import matplotlib.pyplot as plt
18+
import json
1819
from dateutil.relativedelta import relativedelta
1920

2021
logging.basicConfig(level=logging.DEBUG)
2122
logger = logging.getLogger(__name__)
2223
logger.setLevel(logging.DEBUG)
2324

2425

25-
def run(keycloak_user, keycloak_password):
26+
def run(keycloak_user, keycloak_password, save_json=False):
2627
"""Main runner method.
2728
2829
:param keycloak_user: keycloak username
2930
:type keycloak_user: string
3031
:param keycloak_password: keycloak password
3132
:type keycloak_password: string
33+
:param save_json: whether the downloaded user data should be saved to file
34+
:type save_json: bool
3235
3336
"""
3437
keycloak_url = "https://accounts.v2.opensourcebrain.org/auth"
@@ -69,6 +72,11 @@ def run(keycloak_user, keycloak_password):
6972

7073
resp.raise_for_status()
7174
data = resp.json()
75+
76+
if save_json:
77+
with open("osbv2-user-data.json", 'w') as f:
78+
json.dump(data, f)
79+
7280
get_user_trends(data)
7381

7482

0 commit comments

Comments
 (0)