Skip to content

Commit

Permalink
Merge branch 'master' into dev/alexis
Browse files Browse the repository at this point in the history
  • Loading branch information
anmol098 authored Nov 21, 2023
2 parents ba2d9d1 + 159fa91 commit 5a7eda6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
4 changes: 2 additions & 2 deletions sources/graphics_list_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async def make_commit_day_time_list(time_zone: str, repositories: Dict, commit_d
day_times = [0] * 4 # 0 - 6, 6 - 12, 12 - 18, 18 - 24
week_days = [0] * 7 # Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday

for repository in [d for d in repositories["data"]["user"]["repositories"]["nodes"]]:
for repository in repositories:
if repository["name"] not in commit_dates.keys():
continue

Expand Down Expand Up @@ -128,7 +128,7 @@ def make_language_per_repo_list(repositories: Dict) -> str:
:returns: string representation of statistics.
"""
language_count = dict()
repos_with_language = [repo for repo in repositories["data"]["user"]["repositories"]["nodes"] if repo["primaryLanguage"] is not None]
repos_with_language = [repo for repo in repositories if repo["primaryLanguage"] is not None]
for repo in repos_with_language:
language = repo["primaryLanguage"]["name"]
language_count[language] = language_count.get(language, {"count": 0})
Expand Down
7 changes: 3 additions & 4 deletions sources/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,14 @@ async def collect_user_repositories() -> Dict:
"""
DBM.i("Getting user repositories list...")
repositories = await DM.get_remote_graphql("user_repository_list", username=GHM.USER.login, id=GHM.USER.node_id)
repo_names = [repo["name"] for repo in repositories["data"]["user"]["repositories"]["nodes"]]
repo_names = [repo["name"] for repo in repositories]
DBM.g("\tUser repository list collected!")

contributed = await DM.get_remote_graphql("repos_contributed_to", username=GHM.USER.login)
contributed_nodes = [r for r in contributed["data"]["user"]["repositoriesContributedTo"]["nodes"] if r["name"] not in repo_names and not r["isFork"]]
contributed_nodes = [repo for repo in contributed if repo["name"] not in repo_names and not repo["isFork"]]
DBM.g("\tUser contributed to repository list collected!")

repositories["data"]["user"]["repositories"]["nodes"] += contributed_nodes
return repositories
return repositories + contributed_nodes


async def get_stats() -> str:
Expand Down
4 changes: 1 addition & 3 deletions sources/manager_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,7 @@ async def _fetch_graphql_paginated(query: str, **kwargs) -> Dict:
query_response = await DownloadManager._fetch_graphql_query(query, **kwargs, pagination=pagination)
new_page_list, page_info = DownloadManager._find_pagination_and_data_list(query_response)
page_list += new_page_list
_, page_info = DownloadManager._find_pagination_and_data_list(initial_query_response)
page_info.clear()
return initial_query_response
return page_list

@staticmethod
async def get_remote_graphql(query: str, **kwargs) -> Dict:
Expand Down
13 changes: 6 additions & 7 deletions sources/yearly_commit_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!")

Expand All @@ -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:
DBM.w(f"\t\tSkipping repo: {repo_details['name']}")
if len(branch_data) == 0:
DBM.w("\t\tSkipping repo.")
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
Expand Down

0 comments on commit 5a7eda6

Please sign in to comment.