Skip to content

Commit

Permalink
Fixing way metrics are measured
Browse files Browse the repository at this point in the history
  • Loading branch information
Ederporto committed Feb 8, 2024
1 parent 3bef433 commit 6461e8a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions metrics/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def get_metrics_and_aggregate_per_project(project_query=Q(active=True), metric_q
def get_goal_and_done_for_metric(metric):
reports = Report.objects.filter(metrics_related__in=[metric])
goal = get_goal_for_metric(metric)
done = get_done_for_report(reports)
done = get_done_for_report(reports, metric)

return goal, done

Expand Down Expand Up @@ -130,8 +130,8 @@ def get_goal_for_metric(metric):
}


def get_done_for_report(reports):
operation_reports = OperationReport.objects.filter(report__in=reports)
def get_done_for_report(reports, metric):
operation_reports = OperationReport.objects.filter(report__in=reports, metric=metric)
return {
# Content metrics
"Wikipedia": reports.aggregate(total=Sum(F("wikipedia_created") + F("wikipedia_edited")))["total"] or 0,
Expand Down Expand Up @@ -193,7 +193,7 @@ def metrics_reports(request, metric_id):
for goal_key, goal_value in filtered_goals.items():
report_values = []
for report in reports:
done = get_done_for_report(Report.objects.filter(pk=report.id))
done = get_done_for_report(Report.objects.filter(pk=report.id), metric)
report_values.append({
"id": report.id,
"description": report.description,
Expand Down

0 comments on commit 6461e8a

Please sign in to comment.