Skip to content

Commit

Permalink
Adding yes/no metric
Browse files Browse the repository at this point in the history
  • Loading branch information
Ederporto committed Oct 20, 2023
1 parent 207d56d commit 4f3fbee
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions metrics/migrations/0009_metric_boolean_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.7 on 2023-10-20 03:07

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('metrics', '0008_metric_number_of_organizers_retained_and_more'),
]

operations = [
migrations.AddField(
model_name='metric',
name='boolean_type',
field=models.BooleanField(default=False),
),
]
1 change: 1 addition & 0 deletions metrics/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class Metric(models.Model):
number_of_events = models.IntegerField(null=True, default=0)
number_of_people_reached_through_social_media = models.IntegerField(null=True, default=0)

boolean_type = models.BooleanField(default=False)
other_type = models.CharField(null=True, blank=True, max_length=420)
observation = models.CharField(null=True, blank=True, max_length=420)

Expand Down
2 changes: 2 additions & 0 deletions metrics/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def get_metrics_and_aggregate_per_project():
"Number of partnerships": metric.number_of_partnerships,
"Number of organizers": metric.number_of_organizers,
"Number of people reached through social media": metric.number_of_people_reached_through_social_media,
"Is complete": metric.boolean_type,
}
done = {
"Wikipedia": reports.aggregate(total=Sum(F("wikipedia_created") + F("wikipedia_edited")))["total"] or 0,
Expand All @@ -120,6 +121,7 @@ def get_metrics_and_aggregate_per_project():
"Number of partnerships": Partner.objects.filter(partners__in=reports).distinct().count() or 0,
"Number of organizers": Organizer.objects.filter(organizers__in=reports).distinct().count() or 0,
"Number of people reached through social media": reports.aggregate(total=Sum(F("number_of_people_reached_through_social_media")))["total"] or 0,
"Is complete": reports.filter(metrics_related__boolean_type=True).exists() or False,
}

result_metrics = {key: {"goal": value, "done": done[key]} for key, value in goal.items() if value != 0}
Expand Down

0 comments on commit 4f3fbee

Please sign in to comment.