You've already forked wakapi-readme-stats
Merge branch 'master' into master
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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})
|
||||
|
||||
@@ -129,15 +129,15 @@ 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 != None and 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:
|
||||
|
||||
@@ -184,7 +184,7 @@ class DownloadManager:
|
||||
else:
|
||||
res = DownloadManager._REMOTE_RESOURCES_CACHE[resource]
|
||||
DBM.g(f"\tQuery '{resource}' loaded from cache!")
|
||||
if res.status_code == 200:
|
||||
if res.status_code == 200 or res.status_code == 202:
|
||||
if convertor is None:
|
||||
return res.json()
|
||||
else:
|
||||
@@ -271,9 +271,7 @@ class DownloadManager:
|
||||
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:
|
||||
|
||||
@@ -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:
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user