Fixed commit pagination code

This commit is contained in:
pseusys
2023-08-11 05:08:04 +02:00
parent f8cec5f73e
commit 10d35c3401
4 changed files with 11 additions and 15 deletions

View File

@@ -30,11 +30,10 @@ async def calculate_commit_data(repositories: Dict) -> Tuple[Dict, Dict]:
yearly_data = dict()
date_data = dict()
total = len(repositories["data"]["user"]["repositories"]["nodes"])
for ind, repo in enumerate(repositories["data"]["user"]["repositories"]["nodes"]):
for ind, repo in enumerate(repositories):
if repo["name"] not in EM.IGNORED_REPOS:
repo_name = "[private]" if repo["isPrivate"] else f"{repo['owner']['login']}/{repo['name']}"
DBM.i(f"\t{ind + 1}/{total} Retrieving repo: {repo_name}")
DBM.i(f"\t{ind + 1}/{len(repositories)} Retrieving repo: {repo_name}")
await update_data_with_commit_stats(repo, yearly_data, date_data)
DBM.g("Commit data calculated!")
@@ -56,13 +55,13 @@ async def update_data_with_commit_stats(repo_details: Dict, yearly_data: Dict, d
"""
owner = repo_details["owner"]["login"]
branch_data = await DM.get_remote_graphql("repo_branch_list", owner=owner, name=repo_details["name"])
if branch_data["data"]["repository"] is None:
if len(branch_data) == 0:
DBM.w(f"\t\tSkipping repo: {repo_details['name']}")
return
for branch in branch_data["data"]["repository"]["refs"]["nodes"]:
for branch in branch_data:
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"]:
for commit in commit_data:
date = search(r"\d+-\d+-\d+", commit["committedDate"]).group()
curr_year = datetime.fromisoformat(date).year
quarter = (datetime.fromisoformat(date).month - 1) // 3 + 1