File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515import logging
1616import matplotlib
1717import matplotlib .pyplot as plt
18+ import json
1819from dateutil .relativedelta import relativedelta
1920
2021logging .basicConfig (level = logging .DEBUG )
2122logger = logging .getLogger (__name__ )
2223logger .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
You can’t perform that action at this time.
0 commit comments