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

Generating Graph Bug Fixes #272

Merged
merged 2 commits into from
Oct 22, 2024
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
12 changes: 10 additions & 2 deletions scripts/gen_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import datetime
from datetime import timedelta
import re
import pygal

Check warning on line 7 in scripts/gen_graphs.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 E0401: Unable to import 'pygal' (import-error) Raw Output: scripts/gen_graphs.py:7:0: E0401: Unable to import 'pygal' (import-error)

def percent_formatter(x):
"""
Expand All @@ -16,7 +16,7 @@
A string containing the formatted version of x
"""

return '{:0.2f}%'.format(x)

Check warning on line 19 in scripts/gen_graphs.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 C0209: Formatting a regular string which could be an f-string (consider-using-f-string) Raw Output: scripts/gen_graphs.py:19:11: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)

def timedelta_formatter(x):
"""
Expand All @@ -28,7 +28,7 @@
A string containing the formatted version of x
"""

return '{} days'.format(x.days)

Check warning on line 31 in scripts/gen_graphs.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 C0209: Formatting a regular string which could be an f-string (consider-using-f-string) Raw Output: scripts/gen_graphs.py:31:11: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)

def ignore_formatter(x):
"""
Expand Down Expand Up @@ -142,7 +142,7 @@
# print(chart.render_sparkline())
# I have to do this because sparklinees don't have their own subclass and instead
# are rendered through a special method of the Line object.
# TODO: file a pygals issue to make sparklines their own object

Check warning on line 145 in scripts/gen_graphs.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 W0511: TODO: file a pygals issue to make sparklines their own object (fixme) Raw Output: scripts/gen_graphs.py:145:5: W0511: TODO: file a pygals issue to make sparklines their own object (fixme)
_kwargs_ = {
"show_x_labels": False,
"show_y_labels": True,
Expand Down Expand Up @@ -223,6 +223,10 @@
oss_entity.metric_data['issues_count']
except ZeroDivisionError:
open_issue_percent = 0
except TypeError:
print("Repo has no issues")
return

issues_gauge.add(
'Open Issues', [{'value': open_issue_percent * 100, 'max_value': 100}])

Expand Down Expand Up @@ -342,7 +346,7 @@

#This is going to be kind of hacky since pygals doesn't have a
#timeline object
#TODO: Contribute upstream to add a timeline object to pygal

Check warning on line 349 in scripts/gen_graphs.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 W0511: TODO: Contribute upstream to add a timeline object to pygal (fixme) Raw Output: scripts/gen_graphs.py:349:5: W0511: TODO: Contribute upstream to add a timeline object to pygal (fixme)
dateline = pygal.TimeDeltaLine(x_label_rotation=25,legend_at_bottom=True)
dateline.x_value_formatter = timedelta_formatter
dateline.value_formatter = ignore_formatter
Expand Down Expand Up @@ -460,7 +464,7 @@
return

total_loc = sum(entry.get('Code', 0) for entry in language_summary)

Check warning on line 467 in scripts/gen_graphs.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 C0303: Trailing whitespace (trailing-whitespace) Raw Output: scripts/gen_graphs.py:467:0: C0303: Trailing whitespace (trailing-whitespace)
pie_chart.title = f'Language Summary \n Total Source Lines of Code (SLOC): {total_loc:,}'

pie_chart.value_formatter = lambda x: f'{x} SLOC'
Expand Down Expand Up @@ -496,7 +500,7 @@
average_cost = (estimated_cost_low +
estimated_cost_high) / 2

bar_chart.title = f'Estimated Project Costs in $ From Constructive Cost Model (COCOMO) \n Average Cost: ${average_cost:,.2f}'

Check warning on line 503 in scripts/gen_graphs.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 C0301: Line too long (129/100) (line-too-long) Raw Output: scripts/gen_graphs.py:503:0: C0301: Line too long (129/100) (line-too-long)

bar_chart.add(f'Estimated Cost Low (${estimated_cost_low:,.2f})',
estimated_cost_low)
Expand Down Expand Up @@ -532,7 +536,7 @@
bar_chart.title = 'Estimated Project Time in Months From Constructive Cost Model (COCOMO)'

bar_chart.add(None, [0])
bar_chart.add(f'Estimated Time ({formatted_estimated_months:,.1f} mos)',

Check warning on line 539 in scripts/gen_graphs.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 C0303: Trailing whitespace (trailing-whitespace) Raw Output: scripts/gen_graphs.py:539:76: C0303: Trailing whitespace (trailing-whitespace)
estimated_schedule_months_low)
bar_chart.add(None, [0])

Expand Down Expand Up @@ -560,7 +564,7 @@

bar_chart.value_formatter = lambda x: f'{x:,.0f} ppl'

bar_chart.title = 'Estimated Individual Project Contributors From Constructive Cost Model (COCOMO)'

Check warning on line 567 in scripts/gen_graphs.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 C0301: Line too long (103/100) (line-too-long) Raw Output: scripts/gen_graphs.py:567:0: C0301: Line too long (103/100) (line-too-long)

bar_chart.add(None, [0])
bar_chart.add(f'Estimated Contributors ({estimated_people_low:,.0f} ppl)', estimated_people_low)
Expand All @@ -586,12 +590,16 @@
repo_name = data[0]
average_time_str = data[1]

days_str = average_time_str.split(' days ')
days = int(days_str[0])
if "days" in average_time_str:
days_str = average_time_str.split(' days ')
days = int(days_str[0])
else:
print("Average issue resolution time is less than a day")
return

gauge_graph.range = [0, round((days + 20))]

gauge_graph.title = f"Average Issue Resolution Time for {repo_name} \n Average Time: {round(days)} days"

Check warning on line 602 in scripts/gen_graphs.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 C0301: Line too long (108/100) (line-too-long) Raw Output: scripts/gen_graphs.py:602:0: C0301: Line too long (108/100) (line-too-long)
gauge_graph.add("Days", round(days))

write_repo_chart_to_file(oss_entity, gauge_graph, "average_issue_resolution_time")
4 changes: 2 additions & 2 deletions templates/org_report_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ date_stampLastWeek: {date_stamp}
{{% render "graph-section" baseurl: site.baseurl, path: "/{repo_owner}/{repo_owner}_new_issues_by_day_over_last_six_months.svg", title: "New Issues over Last 6 Months" %}}
<!-- Top Committers Bar Graph -->
{{% render "graph-section" baseurl: site.baseurl, path: "/{repo_owner}/{repo_owner}_top_committers.svg", title: "Top Committers" %}}
<!-- Top Committers Bar Graph -->
{{% render "graph-section" baseurl: site.baseurl, path: "/{repo_owner}/{repo_owner}_libyear_timeline.svg", title: "Top Committers" %}}
<!-- Libyear Timeline Graph -->
{{% render "graph-section" baseurl: site.baseurl, path: "/{repo_owner}/{repo_owner}_libyear_timeline.svg", title: "Dependency Libyears" %}}
</div>
</div>
Loading