|
|
|
|
|
|
1
|
from django.shortcuts import render
|
1
|
from django.shortcuts import render
|
|
2
|
from counter.models import Counter,Reset
|
2
|
from counter.models import Counter,Reset
|
|
3
|
from babel.dates import format_timedelta
|
3
|
from babel.dates import format_timedelta
|
|
4
|
-from datetime import datetime
|
|
|
|
|
|
4
|
+from datetime import datetime,timedelta
|
|
5
|
from django import forms
|
5
|
from django import forms
|
|
6
|
from django.http import HttpResponseRedirect
|
6
|
from django.http import HttpResponseRedirect
|
|
7
|
from django.core import serializers
|
7
|
from django.core import serializers
|
|
|
|
|
|
|
20
|
lastResets = []
|
20
|
lastResets = []
|
|
21
|
#Calculates infos for each counter
|
21
|
#Calculates infos for each counter
|
|
22
|
maxJSS = 0
|
22
|
maxJSS = 0
|
|
|
|
23
|
+ timezero = timedelta(0)
|
|
23
|
for counter in counters:
|
24
|
for counter in counters:
|
|
24
|
lastReset = Reset.objects.filter(counter=counter).order_by('-timestamp')
|
25
|
lastReset = Reset.objects.filter(counter=counter).order_by('-timestamp')
|
|
25
|
if (lastReset.count() == 0):
|
26
|
if (lastReset.count() == 0):
|
|
26
|
- counter.lastReset = False
|
|
|
|
|
|
27
|
+ counter.lastReset = Reset()
|
|
|
|
28
|
+ counter.lastReset.delta = timezero
|
|
|
|
29
|
+ counter.lastReset.noSeum = True
|
|
27
|
else:
|
30
|
else:
|
|
28
|
counter.lastReset = lastReset[0]
|
31
|
counter.lastReset = lastReset[0]
|
|
|
|
32
|
+ counter.lastReset.noSeum = False
|
|
29
|
counter.lastReset.delta = datetime.now()-counter.lastReset.timestamp.replace(tzinfo=None)
|
33
|
counter.lastReset.delta = datetime.now()-counter.lastReset.timestamp.replace(tzinfo=None)
|
|
30
|
lastResets.append([counter.trigramme,(counter.lastReset.delta.total_seconds())/(24*3600)])
|
34
|
lastResets.append([counter.trigramme,(counter.lastReset.delta.total_seconds())/(24*3600)])
|
|
31
|
if (counter.lastReset.delta.total_seconds())/(24*3600) > maxJSS:
|
35
|
if (counter.lastReset.delta.total_seconds())/(24*3600) > maxJSS:
|