Skip to content

Commit

Permalink
feat: add repository count (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
devfle authored Oct 11, 2023
1 parent d1647fe commit 054c760
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
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

0 comments on commit 054c760

Please sign in to comment.