Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add repository count #19

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions graphql_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
followers {{
totalCount
}}
RepositoryConnection {{
totalCount
}}
}}
}}
"""
5 changes: 4 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ def generate_content(readme_instance: ReadmeLevel, start_section: str, end_secti

contribution_ep = readme_instance.get_contribution_ep
follower_ep = readme_instance.get_follower_ep
project_ep = readme_instance.get_project_ep


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

return (f"{start_section}\n"
f"{ getenv('INPUT_CARD_TITLE') if getenv('INPUT_CARD_TITLE') else '' } \n"
Expand Down
12 changes: 11 additions & 1 deletion readme_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,30 @@ def calc_current_ep(self) -> int:
# calc the current experience points
self.current_ep = (
user_stats["totalContributions"] * self.level_data.contribution_ep +
user_stats["totalFollowers"] * self.level_data.follower_ep)
user_stats["totalFollowers"] * self.level_data.follower_ep +
user_stats["totalRepositories"] * self.level_data.project_ep)

return self.current_ep

# should be part of data class
@property
def get_contribution_ep(self) -> int:
"""gets the contribution ep"""
return self.level_data.contribution_ep


# should be part of data class
@property
def get_follower_ep(self) -> int:
"""gets the follower ep"""
return self.level_data.follower_ep

# should be part of data class
@property
def get_project_ep(self) -> int:
"""gets the project ep"""
return self.level_data.project_ep

@property
def get_current_level(self) -> dict[str, int]:
"""Calculates user level."""
Expand Down
5 changes: 3 additions & 2 deletions tests/test_readme_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ def test_calc_current_ep(self, mock_fetch_user_data):
"""Tests the ep calc"""
mock_fetch_user_data.return_value = {
"totalContributions": 120,
"totalFollowers": 12
"totalFollowers": 12,
"totalRepositories": 5
}

readme_instance: ReadmeLevel = ReadmeLevel()
readme_instance.calc_current_ep()
self.assertEqual(readme_instance.current_ep, 2700)
self.assertEqual(readme_instance.current_ep, 2725)


if __name__ == '__main__':
Expand Down