diff --git a/scripts/clear_old_metrics.py b/scripts/clear_old_metrics.py index 9c7b759516..f0505ce9b6 100644 --- a/scripts/clear_old_metrics.py +++ b/scripts/clear_old_metrics.py @@ -1,9 +1,7 @@ -import datetime -import json import os import shutil -from metricsLib.constants import BASE_PATH, PATH_TO_METRICS_DATA +from metricsLib.constants import PATH_TO_METRICS_DATA def clear_json_data(): diff --git a/scripts/fetch_public_metrics.py b/scripts/fetch_public_metrics.py index 806e990b24..93b16e7712 100755 --- a/scripts/fetch_public_metrics.py +++ b/scripts/fetch_public_metrics.py @@ -1,26 +1,20 @@ -import datetime - -import json -import os -import requests - -from metricsLib.constants import * +from metricsLib.constants import SIMPLE_METRICS, ORG_METRICS from metricsLib.repos import Repository from metricsLib.orgs import GithubOrg -import re -"""This method serves to iterate through previously collected metric -data that is associated with a repo and derive the cumulative metric data -for the whole organization instead of the repository. -This is mainly to avoid using more api calls than we have to. - -Arguments: - repo_list: List of all repos with metrics - org: The github org to add metrics to -""" def add_info_to_org_from_list_of_repos(repo_list, org): - + """ + This method serves to iterate through previously collected metric + data that is associated with a repo and derive the cumulative metric data + for the whole organization instead of the repository. + + This is mainly to avoid using more api calls than we have to. + + Arguments: + repo_list: List of all repos with metrics + org: The github org to add metrics to + """ #Define counts to update based on tracked repositories. org_counts = {"commits_count": 0, "issues_count": 0, @@ -48,20 +42,6 @@ def add_info_to_org_from_list_of_repos(repo_list, org): org.store_metrics(org_counts) -""" -Purpose: repo_data_to_json will convert data from string to json format such that we can -access the counts for the desired metrics in a repo -Input: Requires a repository name defined from graphql_queries -Returns: json dict of repo data -""" -repos = {} - -def repo_data_to_json(repositories): - for repo in repositories: - repo_json = json.loads(repo) - repos[repo] = repo_json - - def get_all_parsed_data(org_name_list, repo_name_list): all_orgs = [] diff --git a/scripts/metricsLib/constants.py b/scripts/metricsLib/constants.py index c157374566..68a4628996 100644 --- a/scripts/metricsLib/constants.py +++ b/scripts/metricsLib/constants.py @@ -1,9 +1,6 @@ import datetime -import json import os from pathlib import Path -from metricsLib import repos -from metricsLib import orgs from metricsLib.metrics import GraphqlMetric, RangeMetric BASE_PATH = os.path.dirname(os.path.abspath(__file__)) diff --git a/scripts/metricsLib/repos.py b/scripts/metricsLib/repos.py index a09790ec22..2218b4dbd0 100644 --- a/scripts/metricsLib/repos.py +++ b/scripts/metricsLib/repos.py @@ -1,20 +1,22 @@ -import os +import re import json import requests -import datetime -import re -"""This class serves to manage the parameter and metric data of a Repository. -It stores parameter and metric data in two seperate dictionaries for easy JSON -conversion. -Repository's main purpose as a real python class is to encapsulate the mapping -of the db ids in augur to the repos we are trying to gather metrics for. -Arguments: - repo_git_url: Github url -""" class Repository: + """ + This class serves to manage the parameter and metric data of a Repository. + It stores parameter and metric data in two seperate dictionaries for easy JSON + conversion. + + Repository's main purpose as a real python class is to encapsulate the mapping + of the db ids in augur to the repos we are trying to gather metrics for. + + Arguments: + repo_git_url: Github url + + """ def __init__(self, repo_git_url): self.url = repo_git_url