Skip to content

Commit

Permalink
Merge pull request #300 from raquelpanapalen/master
Browse files Browse the repository at this point in the history
Adding university stats
  • Loading branch information
Casassarnau authored Mar 23, 2020
2 parents 479d341 + 4864d13 commit cce08ff
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
48 changes: 48 additions & 0 deletions stats/templates/application_stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ <h3>Confirmed only</h3>
<div id="origin_stats_confirmed"></div>
</div>
</div>
<h2>University</h2>

<div class="row">
<div class="col-md-6">
<h3>All</h3>
<div id="university_stats"></div>
</div>
<div class="col-md-6">
<h3>Confirmed only</h3>
<div id="university_stats_confirmed"></div>
</div>
</div>
<h2>T-Shirts sizes</h2>

<div class="row">
Expand Down Expand Up @@ -237,6 +249,42 @@ <h3>Confirmed only</h3>
}
}
});
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']);
Expand Down
9 changes: 9 additions & 0 deletions stats/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']},
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit cce08ff

Please sign in to comment.