diff --git a/sources/manager_download.py b/sources/manager_download.py index 37e2592..140130a 100644 --- a/sources/manager_download.py +++ b/sources/manager_download.py @@ -225,9 +225,7 @@ class DownloadManager: :param kwargs: Parameters for substitution of variables in dynamic query. :return: Response JSON dictionary. """ - res = await DownloadManager._client.post("https://api.github.com/graphql", json={ - "query": Template(GITHUB_API_QUERIES[query]).substitute(kwargs) - }) + res = await DownloadManager._client.post("https://api.github.com/graphql", json={"query": Template(GITHUB_API_QUERIES[query]).substitute(kwargs)}) if res.status_code == 200: return res.json() else: @@ -266,7 +264,7 @@ class DownloadManager: :param kwargs: Parameters for substitution of variables in dynamic query. :return: Response JSON dictionary. """ - initial_query_response = await DownloadManager._fetch_graphql_query(query, **kwargs, pagination=f"first: 100") + initial_query_response = await DownloadManager._fetch_graphql_query(query, **kwargs, pagination="first: 100") page_list, page_info = DownloadManager._find_pagination_and_data_list(initial_query_response) while page_info["hasNextPage"]: query_response = await DownloadManager._fetch_graphql_query(query, **kwargs, pagination=f'first: 100, after: "{page_info["endCursor"]}"') diff --git a/sources/yearly_commit_calculator.py b/sources/yearly_commit_calculator.py index 8170c7d..458c433 100644 --- a/sources/yearly_commit_calculator.py +++ b/sources/yearly_commit_calculator.py @@ -16,10 +16,10 @@ async def calculate_yearly_commit_data(repositories: Dict) -> Dict: :returns: Commit quarter yearly data dictionary. """ yearly_data = dict() - total = len(repositories['data']['user']['repositories']['nodes']) - for ind, repo in enumerate(repositories['data']['user']['repositories']['nodes']): - if repo['name'] not in EM.IGNORED_REPOS: - print(f"{ind + 1}/{total}", "Retrieving repo:", repo["owner"]["login"], repo['name']) + total = len(repositories["data"]["user"]["repositories"]["nodes"]) + for ind, repo in enumerate(repositories["data"]["user"]["repositories"]["nodes"]): + if repo["name"] not in EM.IGNORED_REPOS: + print(f"{ind + 1}/{total}", "Retrieving repo:", repo["owner"]["login"], repo["name"]) await update_yearly_data_with_commit_stats(repo, yearly_data) return yearly_data @@ -33,13 +33,13 @@ async def update_yearly_data_with_commit_stats(repo_details: Dict, yearly_data: :param yearly_data: Yearly data dictionary to update. """ owner = repo_details["owner"]["login"] - branch_data = await DM.get_remote_graphql("repo_branch_list", owner=owner, name=repo_details['name']) + branch_data = await DM.get_remote_graphql("repo_branch_list", owner=owner, name=repo_details["name"]) if branch_data["data"]["repository"] is None: print(f"\tSkipping repo: {repo_details['name']}") return dict() for branch in branch_data["data"]["repository"]["refs"]["nodes"]: - commit_data = await DM.get_remote_graphql("repo_commit_list", owner=owner, name=repo_details['name'], branch=branch["name"], id=GHM.USER.node_id) + commit_data = await DM.get_remote_graphql("repo_commit_list", owner=owner, name=repo_details["name"], branch=branch["name"], id=GHM.USER.node_id) for commit in commit_data["data"]["repository"]["ref"]["target"]["history"]["nodes"]: date = search(r"\d+-\d+-\d+", commit["committedDate"]).group() curr_year = datetime.fromisoformat(date).year