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

Added Frontend and Backend for Average Issue Resolution Time Graph #269

Merged
merged 6 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
31 changes: 30 additions & 1 deletion scripts/gen_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import datetime
from datetime import timedelta
import re
import random
import pygal


def percent_formatter(x):
"""
Function to format percentage values.
Expand All @@ -17,7 +17,7 @@
A string containing the formatted version of x
"""

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

Check warning on line 20 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:20:11: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)

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

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

Check warning on line 32 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:32:11: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)

def ignore_formatter(x):

Check warning on line 34 in scripts/gen_graphs.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 W0613: Unused argument 'x' (unused-argument) Raw Output: scripts/gen_graphs.py:34:21: W0613: Unused argument 'x' (unused-argument)
"""
Function to ignore values in formatting

Expand Down Expand Up @@ -59,6 +59,7 @@
generate_language_summary_pie_chart(repo)
generate_cost_estimates_bar_chart(repo)
generate_time_estimates_bar_chart(repo)
generate_average_issue_resolution_graph(repo)
try:
generate_donut_graph_line_complexity_graph(repo)
generate_time_xy_issue_graph(
Expand Down Expand Up @@ -104,7 +105,7 @@
except KeyError:
print(f"Org {org.name} has no deps data associated with it!")

def write_repo_chart_to_file(repo, chart, chart_name, custom_func=None, custom_func_params={}):

Check warning on line 108 in scripts/gen_graphs.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 W0102: Dangerous default value {} as argument (dangerous-default-value) Raw Output: scripts/gen_graphs.py:108:0: W0102: Dangerous default value {} as argument (dangerous-default-value)
"""
This function's purpose is to save a pygals chart to a path derived from the
repository object passed in.
Expand Down Expand Up @@ -142,7 +143,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 146 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:146: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 @@ -342,7 +343,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 346 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:346: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 +461,7 @@
return

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

Check warning on line 464 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:464: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 +497,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 500 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:500: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 +533,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 536 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:536:76: C0303: Trailing whitespace (trailing-whitespace)
estimated_schedule_months_low)
bar_chart.add(None, [0])

Expand Down Expand Up @@ -560,10 +561,38 @@

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 564 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:564: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)
bar_chart.add(None, [0])

write_repo_chart_to_file(oss_entity, bar_chart, "estimated_people_contributing")

def generate_average_issue_resolution_graph(oss_entity):
"""
This function generates a pygal gauge chart for average issue resolution time.

Arguments:
oss_entity: An object containing the metric data.
"""
gauge_graph = pygal.Gauge(legend_at_bottom=True)

metric_data = oss_entity.metric_data.get('average_issue_resolution_time')
if not metric_data or not metric_data[0]:
print("No data available for average issue resolution time")
return

data = metric_data[0]
repo_name = data[0]
average_time_str = data[1]

days_str = average_time_str.split(' days ')
days = int(days_str[0])

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

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

write_repo_chart_to_file(oss_entity, gauge_graph, "average_issue_resolution_time")
10 changes: 9 additions & 1 deletion scripts/metricsLib/metrics_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@
AUGUR_HOST + "/pull_request_reports/PR_time_to_first_response/" +
"?repo_id={repo_id}&start_date={begin_month}&end_date={end_date}"))


ORG_GITHUB_GRAPHQL_QUERY = """
query ($org_login: String!) {
organization(login: $org_login) {
Expand Down Expand Up @@ -252,3 +251,12 @@
}
)
)

SIMPLE_METRICS.append(ListMetric("averageIssueResolutionTime", sixMonthsParams, AUGUR_HOST + "/repos/" + "{repo_id}" + "/average-issue-resolution-time", {"average_issue_resolution_time": ["repo_name", "avg_issue_resolution_time"]}))

# Metric for Average Commit Counts per PR
# TODO: - Currently not working because of something wrong on Augur's end. Develop a solution here (hacky) or fix upstream.

# RESOURCE_METRICS.append(ResourceMetric("averageCommitsPerPR", sixMonthsParams,
# AUGUR_HOST + "/pull_request_reports/average_commits_per_PR/" +
# "?repo_id={repo_id}&start_date={begin_month}&end_date={end_date}"))
2 changes: 2 additions & 0 deletions templates/repo_report_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ date_stampLastWeek: {date_stamp}
{{% assign optionsArray = 'Summary, Predominant' | split: ',' %}}
{{% assign graphsArray = "/{repo_owner}/{repo_name}/language_summary_{repo_name}_data.svg, /{repo_owner}/{repo_name}/predominant_langs_{repo_name}_data.svg" | split: ',' %}}
{{% render "graph-toggle" baseurl: site.baseurl, name:"language-information" options: optionsArray, graphs: graphsArray, title: "Language Information" %}}
<!-- Average Issue Resolution Time -->
{{% render "graph-section" baseurl: site.baseurl, path: "/{repo_owner}/{repo_name}/average_issue_resolution_time_{repo_name}_data.svg", title: "Average Issue Resolution Time" %}}
<!-- Libyear Timeline Graph -->
{{% render "graph-section" baseurl: site.baseurl, path: "/{repo_owner}/{repo_name}/libyear_timeline_{repo_name}_data.svg", title: "Dependency Libyears" %}}
<!-- DRYness Percentages Graph -->
Expand Down
Loading