From e2e11f2eecedc10579bd93054ff8833174ffada6 Mon Sep 17 00:00:00 2001 From: raquelpanapalen <57674236+raquelpanapalen@users.noreply.github.com> Date: Mon, 23 Mar 2020 19:37:45 +0100 Subject: [PATCH 1/2] Add files via upload --- stats/views.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/stats/views.py b/stats/views.py index 5573f170..ea4d6ae9 100644 --- a/stats/views.py +++ b/stats/views.py @@ -66,6 +66,13 @@ def app_stats_api(request): .annotate(applications=Count('origin')) \ .order_by('-applications')[:10] + university_count = Application.objects.all().values('university') \ + .annotate(applications=Count('university')) \ + .order_by('-applications')[:10] + university_count_confirmed = Application.objects.filter(status=APP_CONFIRMED).values('university') \ + .annotate(applications=Count('university')) \ + .order_by('-applications')[:10] + tshirt_dict = dict(a_models.TSHIRT_SIZES) shirt_count = map( lambda x: {'tshirt_size': tshirt_dict.get(x['tshirt_size'], 'Unknown'), 'applications': x['applications']}, @@ -95,6 +102,8 @@ def app_stats_api(request): 'shirt_count_confirmed': list(shirt_count_confirmed), 'timeseries': list(timeseries), 'gender': list(gender_count), + 'university': list(university_count), + 'university_confirmed': list(university_count_confirmed), 'origin': list(origin_count), 'origin_confirmed': list(origin_count_confirmed), 'diet': list(diet_count), From b6d5334576828d8c6cab716cbb1cb678224ae448 Mon Sep 17 00:00:00 2001 From: raquelpanapalen <57674236+raquelpanapalen@users.noreply.github.com> Date: Mon, 23 Mar 2020 19:38:59 +0100 Subject: [PATCH 2/2] Add files via upload --- stats/templates/application_stats.html | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/stats/templates/application_stats.html b/stats/templates/application_stats.html index c242860c..075d57ed 100644 --- a/stats/templates/application_stats.html +++ b/stats/templates/application_stats.html @@ -33,6 +33,18 @@

Confirmed only

+

University

+ +
+
+

All

+
+
+
+

Confirmed only

+
+
+

T-Shirts sizes

@@ -237,6 +249,42 @@

Confirmed only

} } }); + c3.generate({ + bindto: '#university_stats', + data: { + json: data['university'], + keys: { + x: 'university', + value: ['applications'] + }, + type: 'bar' + + }, + + axis: { + x: { + type: 'category' + } + } + }); + c3.generate({ + bindto: '#university_stats_confirmed', + data: { + json: data['university_confirmed'], + keys: { + x: 'university', + value: ['applications'] + }, + type: 'bar' + + }, + + axis: { + x: { + type: 'category' + } + } + }); $('#other_diet').html(data['other_diet']); $('#update_date').html(data['update_time']); $('#app_count').html(data['app_count']);