Skip to content

Commit

Permalink
feat: show warning about private profile when there are 0 stats
Browse files Browse the repository at this point in the history
Future improvement:
Right now, in their api, github does not expose the information
about whether the user has made there profile private or not. If
they do so, we can update the logic to avoid making stats API call
if the profile is private and the user's token is not there.
  • Loading branch information
makkoncept committed Oct 9, 2022
1 parent 4653f19 commit 20042a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion ghs/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def render_general_stats(username, general_stats, spinner):
print(text, end="")
output_text += text

if total_prs + total_contribution + total_issues + total_repositories + total_stars + total_forks + total_packages + total_releases == 0:
output_text += render_private_profile_warning(username)

output_text += render_generated_on()

return output_text
Expand All @@ -44,6 +47,12 @@ def render_generated_on():
return text


def render_private_profile_warning(username):
text = f"\nIt's possible that {username} has made their contributions private. Use {username}'s token token to get their correct contributions stats."
cprint(text, "yellow")
return text


def _render_top_contribution(top_contribution_data):
text = f"\nYour Top Contributions:\n"
print(text)
Expand Down Expand Up @@ -108,7 +117,7 @@ def render_user_summary(
output_text += text
cprint(text, color="cyan")
if total_commit_contributions == 0:
text = "No code contribution during this period\n"
text = "No public code contribution during this period\n"
print(text, end="")
output_text += text
else:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[pep8]
indent-size = 2
indent-size = 4
max-line-length = 100

0 comments on commit 20042a9

Please sign in to comment.