import firebase_client_wrapper as fcw import json import sys from time import gmtime, strftime if __name__ == "__main__": if len(sys.argv) != 2: print("Usage python compute_coding_progress.py coda_crypto_token") exit(1) CODA_CRYPTO_TOKEN_PATH = sys.argv[1] fcw.init_client(CODA_CRYPTO_TOKEN_PATH) data = {} ids = fcw.get_segment_ids() data['coding_progress'] = {} for segment_id in ids: data['coding_progress'][segment_id] = fcw.compute_segment_coding_progress(segment_id) data["last_update"] = strftime("%Y-%m-%d %H:%M:%S", gmtime()) print(json.dumps(data, indent=2))
parser.add_argument("content_type", metavar="content-type", choices=["all", "users", "schemes", "messages"], help="Type of data to download") args = parser.parse_args() previous_export_file_path = args.previous_export_file_path crypto_token_path = args.crypto_token_path dataset_id = args.dataset_id content_type = args.content_type assert previous_export_file_path is None or content_type not in {"users", "schemes"}, \ "Cannot use previous-export-file-path with content-type 'users' or 'schemes'" fcw.init_client(crypto_token_path) if content_type in ["all", "users"]: if content_type == "all": print("Users:") print(json.dumps(fcw.get_user_ids(dataset_id), indent=2)) if content_type in ["all", "schemes"]: if content_type == "all": print("Schemes:") schemes = fcw.get_all_code_schemes(dataset_id) print(json.dumps(schemes, indent=2)) if content_type in ["all", "messages"]: if content_type == "all": print("Messages:")
metavar="dataset-id", help="Id of dataset to add data to") parser.add_argument("content_type", choices=["schemes", "messages"], help="Type of data to add") parser.add_argument("path", help="Path to a JSON file containing the data to add") args = parser.parse_args() firestore_credentials_file_path = args.firestore_credentials_file_path dataset_id = args.dataset_id content_type = args.content_type path = args.path fcw.init_client(firestore_credentials_file_path) dataset_ids = fcw.get_dataset_ids() if dataset_id not in dataset_ids: print( f"WARNING: dataset {dataset_id} does not exist, this will create a new dataset" ) json_data = json.loads(open(path).read()) if content_type == "users": pass # Not implemented elif content_type == "schemes": added = 0 skipped_existing = 0
import firebase_client_wrapper as fcw import json import sys if (len(sys.argv) != 3): print( "Usage python push_coding_progress.py dashboard_crypto_token progress_file" ) exit(1) DASHBOARD_CRYPTO_TOKEN_PATH = sys.argv[1] PROGRESS_FILE = sys.argv[2] fcw.init_client(DASHBOARD_CRYPTO_TOKEN_PATH) data = json.load(open(PROGRESS_FILE, 'r')) fcw.push_coding_status(data)