Skip to content

Commit

Permalink
Merge pull request #28 from github/div0
Browse files Browse the repository at this point in the history
Catch divide by zero case for no new contributors
  • Loading branch information
zkoppert authored Oct 14, 2023
2 parents 23c5c07 + 77e5650 commit 2b38713
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,22 @@ def get_summary_table(collaborators, start_date, end_date, total_contributions):
"""
if start_date and end_date:
summary_table = "| Total Contributors | Total Contributions | % New Contributors |\n| --- | --- | --- |\n"
if len(collaborators) > 0:
new_contributors_percentage = round(
(len([x for x in collaborators if x.new_contributor is True]))
/ len(collaborators)
* 100,
2,
)
else:
new_contributors_percentage = 0
summary_table += (
"| "
+ str(len(collaborators))
+ " | "
+ str(total_contributions)
+ " | "
+ str(
round(
(len([x for x in collaborators if x.new_contributor is True]))
/ len(collaborators)
* 100,
2,
)
)
+ str(new_contributors_percentage)
+ "% |\n\n"
)
else:
Expand Down

0 comments on commit 2b38713

Please sign in to comment.