Skip to content

Commit

Permalink
feat: add follower count to calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
devfle committed Jan 2, 2023
1 parent 00d7f9e commit 743a67b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions graphql_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
totalContributions
}}
}}
followers {{
totalCount
}}
}}
}}
"""
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ def draw_progress_bar(current_progress: float | int) -> str:
"percentage_level")(readme_instance.calc_current_level())

CONTRIBUTION_EP = readme_instance.contribution_ep
FOLLOWER_EP = readme_instance.follower_ep
# should be generated in later versions
ep_information = f"<pre>💪 1x contribute → { CONTRIBUTION_EP } experience points</pre>\n"
ep_information = (f"<pre>💪 1x contribute → { CONTRIBUTION_EP } experience points\n"
f"🌟 1x follower → { FOLLOWER_EP } experience points</pre>\n")

readme_path: str = getenv("INPUT_README_PATH")
start_section: str = "<!--README_LEVEL_UP:START-->"
Expand Down
8 changes: 6 additions & 2 deletions readme_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ReadmeLevel:
project_ep: int = 5
discussion_ep: int = 10
star_ep: int = 40
follower_ep: int = 50
follower_ep: int = 25

def __init__(self) -> None:
pass
Expand All @@ -42,9 +42,13 @@ def fetch_user_data(self) -> dict[str, int] | None:

if response.status_code == 200:
response_data = response.json()

user_data = (response_data["data"]["user"]
["contributionsCollection"]["contributionCalendar"])

user_data["totalFollowers"] = (response_data["data"]["user"]
["followers"]["totalCount"])

return user_data

error("request to github api failed")
Expand All @@ -61,7 +65,7 @@ def _update_user_data(self) -> None:
key_mapper = {
"totalContributions": "contribution_count",
"projects": "project_count",
"follower": "follower_count",
"totalFollowers": "follower_count",
"discussions": "discussion_count"
}

Expand Down

0 comments on commit 743a67b

Please sign in to comment.