Commit 6a1ba4f3 authored by Elger Jonker's avatar Elger Jonker

Fix #134, created a new relative score


Former-commit-id: 110cbcc5
parent 1d356c3d
......@@ -1300,7 +1300,7 @@ function views() {
el: '#topfail',
data: {
data_url: "/data/topfail/",
sortOrders: {'rank': 1, 'organization_id': 1, 'high': 1, 'medium': 1, 'low': 1}
sortOrders: {'rank': 1, 'organization_id': 1, 'high': 1, 'medium': 1, 'low': 1, 'relative': 1, 'total_urls': 1, 'total_endpoints': 1}
},
mixins: [top_mixin, state_mixin]
});
......
......@@ -36,6 +36,9 @@
<th @click="sortBy('low')" :class="{ active: sortKey == 'low' }">{% trans "Low" %}
<span class="arrow" :class="sortOrders['low'] > 0 ? 'asc' : 'dsc'">
</span></th>
<th @click="sortBy('relative')" :class="{ active: sortKey == 'relative' }">{% trans "Relative" %}
<span class="arrow" :class="sortOrders['relative'] > 0 ? 'asc' : 'dsc'">
</span></th>
</tr>
</thead>
<tbody>
......@@ -48,6 +51,7 @@
<td>{{ rank['high'] }}</td>
<td>{{ rank['medium'] }}</td>
<td>{{ rank['low'] }}</td>
<td>{{ rank['relative'] }}</td>
{% endverbatim %}
</tr>
</tbody>
......
......@@ -2,6 +2,7 @@ import collections
import logging
import re
from datetime import datetime, timedelta
from math import ceil
import pytz
import simplejson as json
......@@ -628,7 +629,14 @@ def top_fail(request, country: str = "NL", organization_type="municipality", wee
"medium": i[7],
"low": i[8],
"total_urls": i[9],
"total_endpoints": i[10]
"total_endpoints": i[10],
"high_div_endpoints": "%s" % ceil((int(i[6]) / int(i[10])) * 100),
"mid_div_endpoints": "%s" % ceil((int(i[7]) / int(i[10])) * 100),
"low_div_endpoints": "%s" % ceil((int(i[8]) / int(i[10])) * 100),
# Add all percentages, which is sort of an indication how bad / well the organization is doing overall.
"relative": ceil((int(i[6]) / int(i[10])) * 1000) + ceil((int(i[7]) / int(i[10])) * 100) +
ceil((int(i[8]) / int(i[10])) * 10)
}
rank = rank + 1
......
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