summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2012-10-21 14:27:59 +0200
committerLeif Johansson <leifj@sunet.se>2012-10-21 14:27:59 +0200
commit9916a5e01f601ce7bb4a620169bac347515496b4 (patch)
tree87bac5306cbc090d89beaeb2164251ffb208e8c0
parent0fddaaa6eabf7aa875a660b6e98d1e680d003976 (diff)
sensible 48 hrs for domain stats
-rw-r--r--meetingtools/apps/stats/views.py16
-rw-r--r--templates/apps/stats/domain.html4
2 files changed, 19 insertions, 1 deletions
diff --git a/meetingtools/apps/stats/views.py b/meetingtools/apps/stats/views.py
index 6a0c1ae..7e94ab6 100644
--- a/meetingtools/apps/stats/views.py
+++ b/meetingtools/apps/stats/views.py
@@ -5,6 +5,7 @@ Created on Jan 16, 2012
"""
from django.contrib.auth.decorators import login_required
+from django.contrib.humanize.templatetags.humanize import naturalday
from django.http import HttpResponseForbidden, HttpResponseBadRequest
from meetingtools.ac import ac_api_client
from iso8601 import iso8601
@@ -142,11 +143,19 @@ def domain_minutes_api(request,domain):
begin = form.cleaned_data['begin']
end = form.cleaned_data['end']
+
+ if begin is None:
+ from datetime import datetime,timedelta
+ begin = datetime.now()-timedelta(seconds=48*3600)
+ begin = begin.replace(microsecond=0)
if begin is not None:
p['filter-gte-date-created'] = begin
if end is not None:
p['filter-lt-date-created'] = end
+ else:
+ end = datetime.now().replace(microsecond=0) # for display only
+
r = api.request('report-bulk-consolidated-transactions',p)
series = []
@@ -200,7 +209,12 @@ def domain_minutes_api(request,domain):
if curdate is not None and ms > 0:
series.append([_date_ts(curdate),int(ms/60000)])
- return json_response({'data': sorted(series,key=lambda x: x[0]), 'rooms': len(rc.keys()), 'users': len(uc.keys()), 'minutes': int(t_ms/60000)},request)
+ return json_response({'data': sorted(series,key=lambda x: x[0]),
+ 'rooms': len(rc.keys()),
+ 'begin': naturalday(begin),
+ 'end': naturalday(end),
+ 'users': len(uc.keys()),
+ 'minutes': int(t_ms/60000)},request)
@login_required
diff --git a/templates/apps/stats/domain.html b/templates/apps/stats/domain.html
index 132d819..301d545 100644
--- a/templates/apps/stats/domain.html
+++ b/templates/apps/stats/domain.html
@@ -17,6 +17,8 @@
$('#minutes').append(resp['minutes']);
$('#rooms').append(resp['rooms']);
$('#users').append(resp['users']);
+ $('#begin').append(resp['begin']));
+ $('#end').append(resp['end']));
}
});
{% endblock %}
@@ -29,6 +31,8 @@
<tr><td><b>Total minutes:</b></td><td id="minutes"></td></tr>
<tr><td><b>Total rooms:</b></td><td id="rooms"></td></tr>
<tr><td><b>Total unique users:</b></td><td id="users"></td></tr>
+ <tr><td><b>Start time:</b></td><td id="begin"></td></tr>
+ <tr><td><b>End time:</b></td><td id="end"></td></tr>
<tr><td colspan="2" style="padding-top: 10px;"><a href="/stats">Look at your own statistics</a></td></tr>
</table>
</div>