Commit 4bf75d65 authored by Enrico Zini's avatar Enrico Zini
Browse files

Show mbox stats in process view

parent ac3aa0c2
......@@ -4,7 +4,7 @@
{% block head_resources %}
{{block.super}}
{% jsinclude "nm" %}
{% jsinclude "nm,sparkline" %}
{% endblock %}
{% block head %}
......@@ -61,6 +61,14 @@ $(function() {
shortcuts_found = true;
});
$("#shortcuts").toggle(shortcuts_found);
$(".mbox_sparkline").sparkline("html", {
type: "bar",
barColor: "#005382",
negBarColor: "#823000",
chartRangeMin: 0,
chartRangeMax: 30
});
});
</script>
{% endblock %}
......@@ -145,6 +153,16 @@ See: <a href="http://lists.debian.org/debian-project/2010/09/msg00026.html">hand
(no mail archive yet)
{% endif %}
</td>
</tr>
<tr><th>Mailbox stats</th>
<td>{{mbox_stats.date_first_py|date:"Y-m-d"}} to {{mbox_stats.date_last_py|date:"Y-m-d"}},
{{mbox_stats.num_mails}} mails,
{% if mbox_stats.median_py %}
{% if mbox_stats.median_py.days %}{{mbox_stats.median_py.days}}d {% endif %}{{mbox_stats.median_hours}}h
{% endif %}
<span class="mbox_sparkline" values="{{mbox_stats.response_time|join:","}}"></span>
</td>
</tr>
{% endif %}
</table>
{% if "edit_bio" in vperms.perms or "edit_ldap" in vperms.perms %}
......
......@@ -21,6 +21,7 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from django import http, forms
from django.conf import settings
from django.shortcuts import redirect, render, get_object_or_404
from django.core.urlresolvers import reverse
from django.core.exceptions import PermissionDenied
......@@ -35,6 +36,7 @@ from backend.mixins import VisitorMixin, VisitorTemplateView, VisitPersonTemplat
from .email_stats import mailbox_get_gaps
import markdown
import datetime
import os
import json
def lookup_or_404(dict, key):
......@@ -215,6 +217,24 @@ class Process(VisitorTemplateView):
if self.visitor:
ctx["wizards"] = self.build_wizards(process)
# Mailbox statistics
# TODO: move saving per-process stats into a JSON field in Process
try:
with open(os.path.join(settings.DATA_DIR, 'mbox_stats.json'), "rt") as infd:
stats = json.load(infd)
except OSError:
stats = {}
stats = stats.get("process", {})
stats = stats.get(process.lookup_key, {})
stats["date_first_py"] = datetime.datetime.fromtimestamp(stats["date_first"])
stats["date_last_py"] = datetime.datetime.fromtimestamp(stats["date_last"])
if "median" not in stats or stats["median"] is None:
stats["median_py"] = None
else:
stats["median_py"] = datetime.timedelta(seconds=stats["median"])
stats["median_hours"] = stats["median_py"].seconds // 3600
ctx["mbox_stats"] = stats
return ctx
def build_wizards(self, process):
......
Supports Markdown
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