From b38983e184c649bc28b751974cd55c467e35c620 Mon Sep 17 00:00:00 2001 From: raquelpanapalen <57674236+raquelpanapalen@users.noreply.github.com> Date: Tue, 24 Mar 2020 18:24:57 +0100 Subject: [PATCH 1/2] Add files via upload --- stats/views.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stats/views.py b/stats/views.py index ea4d6ae9..b1ccaaff 100644 --- a/stats/views.py +++ b/stats/views.py @@ -73,6 +73,11 @@ def app_stats_api(request): .annotate(applications=Count('university')) \ .order_by('-applications')[:10] + grad_year_count = Application.objects.all().values('graduation_year') \ + .annotate(applications=Count('graduation_year')) + grad_year_count_confirmed = Application.objects.filter(status=APP_CONFIRMED).values('graduation_year') \ + .annotate(applications=Count('graduation_year')) + tshirt_dict = dict(a_models.TSHIRT_SIZES) shirt_count = map( lambda x: {'tshirt_size': tshirt_dict.get(x['tshirt_size'], 'Unknown'), 'applications': x['applications']}, @@ -104,6 +109,8 @@ def app_stats_api(request): 'gender': list(gender_count), 'university': list(university_count), 'university_confirmed': list(university_count_confirmed), + 'graduation_year': list(grad_year_count), + 'graduation_year_confirmed': list(grad_year_count_confirmed), 'origin': list(origin_count), 'origin_confirmed': list(origin_count_confirmed), 'diet': list(diet_count), From b41ecbfc3ef08787494c603ec96742502e6f43f1 Mon Sep 17 00:00:00 2001 From: raquelpanapalen <57674236+raquelpanapalen@users.noreply.github.com> Date: Tue, 24 Mar 2020 18:33:44 +0100 Subject: [PATCH 2/2] Add files via upload --- stats/templates/application_stats.html | 55 ++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/stats/templates/application_stats.html b/stats/templates/application_stats.html index 075d57ed..a2759917 100644 --- a/stats/templates/application_stats.html +++ b/stats/templates/application_stats.html @@ -45,6 +45,19 @@

Confirmed only

+ +

Graduation year

+ +
+
+

All

+
+
+
+

Confirmed only

+
+
+

T-Shirts sizes

@@ -285,6 +298,48 @@

Confirmed only

} } }); + var grad_year_data = {}; + var grad_years = []; + $(data['graduation_year']).each(function (c, e) { + grad_years.push(e.graduation_year); + grad_year_data[e.graduation_year] = e.applications; + }); + c3.generate({ + bindto: '#graduation_year_stats', + data: { + json: grad_year_data, + type: 'donut' + + }, + donut: { + label: { + format: function (value, ratio, id) { + return value; + } + } + } + }); + var grad_year_confirmed_data = {}; + var grad_years_confirmed = []; + $(data['graduation_year_confirmed']).each(function (c, e) { + grad_years_confirmed.push(e.graduation_year); + grad_year_confirmed_data[e.graduation_year] = e.applications; + }); + c3.generate({ + bindto: '#graduation_year_stats_confirmed', + data: { + json: grad_year_confirmed_data, + type: 'donut' + + }, + donut: { + label: { + format: function (value, ratio, id) { + return value; + } + } + } + }); $('#other_diet').html(data['other_diet']); $('#update_date').html(data['update_time']); $('#app_count').html(data['app_count']);