Commit b527cccd authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Merge branch '58-improve-statistics-pizza' into 'master'

Resolve "Improve statistics"

See merge request !789
parents 735514e6 726d7236
......@@ -48,6 +48,14 @@ pizzas\.models module
:undoc-members:
:show-inheritance:
pizzas\.services module
-----------------------
.. automodule:: pizzas.services
:members:
:undoc-members:
:show-inheritance:
pizzas\.urls module
-------------------
......
......@@ -7,77 +7,79 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-09-21 20:03+0200\n"
"PO-Revision-Date: 2016-09-21 20:04+0200\n"
"POT-Creation-Date: 2018-05-16 19:20+0200\n"
"PO-Revision-Date: 2018-05-16 19:22+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Last-Translator: \n"
"Language-Team: \n"
"X-Generator: Poedit 1.8.9\n"
"X-Generator: Poedit 1.8.7.1\n"
#: members/static/members/js/statistics.js:50
#: static/members/js/statistics.js:50
msgid "Members per member type"
msgstr "Leden per lidtype"
#: members/static/members/js/statistics.js:59
#: static/members/js/statistics.js:59
msgid "Members"
msgstr "Leden"
#: members/static/members/js/statistics.js:62
#: static/members/js/statistics.js:62
msgid "Supporters"
msgstr "Begunstigers"
#: members/static/members/js/statistics.js:65
#: static/members/js/statistics.js:65
msgid "Honorary Members"
msgstr "Ereleden"
#: members/static/members/js/statistics.js:76
#: static/members/js/statistics.js:76
msgid "Total members per year"
msgstr "Aantal leden per jaar"
#: members/static/members/js/statistics.js:85
#: members/static/members/js/statistics.js:120
#: members/static/members/js/statistics.js:156
#: static/members/js/statistics.js:85 static/members/js/statistics.js:120
#: static/members/js/statistics.js:156
msgid "1st year"
msgstr "Eerstejaars"
#: members/static/members/js/statistics.js:88
#: members/static/members/js/statistics.js:123
#: members/static/members/js/statistics.js:159
#: static/members/js/statistics.js:88 static/members/js/statistics.js:123
#: static/members/js/statistics.js:159
msgid "2nd year"
msgstr "Tweedejaars"
#: members/static/members/js/statistics.js:91
#: members/static/members/js/statistics.js:126
#: members/static/members/js/statistics.js:162
#: static/members/js/statistics.js:91 static/members/js/statistics.js:126
#: static/members/js/statistics.js:162
msgid "3rd year"
msgstr "Derdejaars"
#: members/static/members/js/statistics.js:94
#: members/static/members/js/statistics.js:129
#: members/static/members/js/statistics.js:165
#: static/members/js/statistics.js:94 static/members/js/statistics.js:129
#: static/members/js/statistics.js:165
msgid "4th year"
msgstr "Vierdejaars"
#: members/static/members/js/statistics.js:97
#: members/static/members/js/statistics.js:132
#: members/static/members/js/statistics.js:168
#: static/members/js/statistics.js:97 static/members/js/statistics.js:132
#: static/members/js/statistics.js:168
msgid "5th year"
msgstr "Vijfdejaars"
#: members/static/members/js/statistics.js:100
#: members/static/members/js/statistics.js:135
#: members/static/members/js/statistics.js:171
#: static/members/js/statistics.js:100 static/members/js/statistics.js:135
#: static/members/js/statistics.js:171
msgid ">5th year"
msgstr "Ouderejaars"
#: members/static/members/js/statistics.js:111
#: static/members/js/statistics.js:111
msgid "Members per year"
msgstr "Leden per jaar"
#: members/static/members/js/statistics.js:147
#: static/members/js/statistics.js:147
msgid "Supporters per year"
msgstr "Begunstigers per jaar"
#: static/members/js/statistics.js:182
msgid "Total pizza orders of type"
msgstr "Totaal aantal pizza bestellingen per soort"
#: static/members/js/statistics.js:218
msgid "Current pizza orders of type"
msgstr "Aantal pizza bestellingen van het huidige event per soort"
......@@ -173,4 +173,76 @@ $(function () {
}]
}]
});
$('#pizzaTotalTypeChart').highcharts({
chart: {
type: 'pie'
},
title: {
text: gettext("Total pizza orders of type"),
},
plotOptions: {
pie: pieOptions
},
series: [{
name: 'Pizzas',
colorByPoint: true,
data : [{
name: total_pizza_orders[0].name,
y: total_pizza_orders[0].total
},{
name: total_pizza_orders[1].name,
y: total_pizza_orders[1].total
},{
name: total_pizza_orders[2].name,
y: total_pizza_orders[2].total
},{
name: total_pizza_orders[3].name,
y: total_pizza_orders[3].total
},{
name: total_pizza_orders[4].name,
y: total_pizza_orders[4].total
},{
name: total_pizza_orders[5].name,
y: total_pizza_orders[5].total
}]
}]
});
if (current_pizza_orders != null) {
$('#pizzaCurrentTypeChart').highcharts({
chart: {
type: 'pie'
},
title: {
text: gettext("Current pizza orders of type"),
},
plotOptions: {
pie: pieOptions
},
series: [{
name: 'Pizzas',
colorByPoint: true,
data : [{
name: current_pizza_orders[0].name,
y: current_pizza_orders[0].total
},{
name: current_pizza_orders[1].name,
y: current_pizza_orders[1].total
},{
name: current_pizza_orders[2].name,
y: current_pizza_orders[2].total
},{
name: current_pizza_orders[3].name,
y: current_pizza_orders[3].total
},{
name: current_pizza_orders[4].name,
y: current_pizza_orders[4].total
},{
name: current_pizza_orders[5].name,
y: current_pizza_orders[5].total
}]
}]
});
}
});
......@@ -14,6 +14,10 @@
<div id="totalYearChart" style="width:100%; height:400px;"></div>
<div id="membersYearChart" style="width:100%; height:400px;"></div>
<div id="supportersYearChart" style="width:100%; height:400px;"></div>
<div id="pizzaTotalTypeChart" style="width:100%; height:400px;"></div>
{% if current_pizza_orders != 'null' %} {# None is json-serialized to 'null' #}
<div id="pizzaCurrentTypeChart" style="width:100%; height:400px;"></div>
{% endif %}
<br/><br/>
{% endblock %}
......@@ -29,6 +33,8 @@
{% autoescape off %}
var total_stats_year = {{ total_stats_year }};
var total_stats_member_type = {{ total_stats_member_type }};
var total_pizza_orders = {{ total_pizza_orders }};
var current_pizza_orders = {{ current_pizza_orders }};
{% endautoescape %}
</script>
......
......@@ -16,6 +16,7 @@ from members import services
from .services import member_achievements
from . import models
from .forms import ProfileForm
import pizzas.services
class ObtainThaliaAuthToken(ObtainAuthToken):
......@@ -217,6 +218,10 @@ def statistics(request):
"total_stats_year": json.dumps(services.gen_stats_year(member_types)),
"total_stats_member_type": json.dumps(
services.gen_stats_member_type(member_types)),
"total_pizza_orders": json.dumps(
pizzas.services.gen_stats_pizza_orders()),
"current_pizza_orders": json.dumps(
pizzas.services.gen_stats_current_pizza_orders()),
}
return render(request, 'members/statistics.html', context)
from . models import Product, Order, PizzaEvent
def gen_stats_pizza_orders():
total = []
for product in Product.objects.all():
total.append({
'name': product.name,
'total': Order.objects.filter(product=product).count(),
})
total.sort(key=lambda prod: prod['total'], reverse=True)
return total
def gen_stats_current_pizza_orders():
total = []
current_pizza_event = PizzaEvent.current()
if not current_pizza_event:
return None
for product in Product.objects.filter():
total.append({
'name': product.name,
'total': Order.objects.filter(
product=product,
pizza_event=current_pizza_event,
).count(),
})
total.sort(key=lambda prod: prod['total'], reverse=True)
return total
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment