|
|
@@ -24,11 +24,12 @@ class resetCounterForm(forms.ModelForm):
|
|
24
|
24
|
def home(request):
|
|
25
|
25
|
# JSS above this limit will not be displayed on the col graph
|
|
26
|
26
|
JSS_limit = 7
|
|
|
27
|
+ maxJSS = 0
|
|
|
28
|
+ bestSeumeursNumber = 15
|
|
27
|
29
|
# Display counters
|
|
28
|
30
|
counters = Counter.objects.all()
|
|
29
|
31
|
lastResets = []
|
|
30
|
32
|
# Calculates infos for each counter
|
|
31
|
|
- maxJSS = 0
|
|
32
|
33
|
timezero = timedelta(0)
|
|
33
|
34
|
for counter in counters:
|
|
34
|
35
|
lastReset = Reset.objects.filter(
|
|
|
@@ -130,13 +131,34 @@ def home(request):
|
|
130
|
131
|
'legend': 'none',
|
|
131
|
132
|
'height': 90
|
|
132
|
133
|
})
|
|
|
134
|
+ # Graph of greatest seumers
|
|
|
135
|
+ seumCounts = []
|
|
|
136
|
+ for counter in counters:
|
|
|
137
|
+ seumCounts.append([counter.trigramme, Reset.objects.filter(
|
|
|
138
|
+ counter=counter).count()])
|
|
|
139
|
+ if (len(seumCounts) == 0):
|
|
|
140
|
+ noBestSeum = True
|
|
|
141
|
+ best_chart = None
|
|
|
142
|
+ else:
|
|
|
143
|
+ seumCounts.sort(key=lambda x: -x[1])
|
|
|
144
|
+ noBestSeum = False
|
|
|
145
|
+ seumCounts.insert(0, ['Trigramme', 'Nombre de seums'])
|
|
|
146
|
+ best_data = SimpleDataSource(seumCounts[:bestSeumeursNumber])
|
|
|
147
|
+ best_chart = gchart.ColumnChart(best_data, options={
|
|
|
148
|
+ 'title': '',
|
|
|
149
|
+ 'legend': 'none',
|
|
|
150
|
+ 'vAxis': {'title': 'Nombre de seums'},
|
|
|
151
|
+ 'hAxis': {'title': 'Trigramme'},
|
|
|
152
|
+ })
|
|
133
|
153
|
|
|
134
|
154
|
return render(request, 'homeTemplate.html', {
|
|
135
|
155
|
'counters': counters,
|
|
136
|
156
|
'col_chart': col_chart,
|
|
137
|
157
|
'line_chart': line_chart,
|
|
|
158
|
+ 'best_chart': best_chart,
|
|
138
|
159
|
'noTimeline': noTimeline,
|
|
139
|
|
- 'noGraph': noGraph
|
|
|
160
|
+ 'noGraph': noGraph,
|
|
|
161
|
+ 'noBestSeum': noBestSeum
|
|
140
|
162
|
})
|
|
141
|
163
|
|
|
142
|
164
|
|