Permalink
Browse files

[bug 849843] Add responded in 24 hours series to kpi graph.

  • Loading branch information...
rlr committed Mar 19, 2013
1 parent 558e8e3 commit b45a8f802e4ec1bcf5da11bf4cf165909ce44af0
Showing with 26 additions and 9 deletions.
  1. +13 −5 apps/kpi/api.py
  2. +2 −2 apps/kpi/templates/kpi/dashboard.html
  3. +2 −1 apps/kpi/tests/test_api.py
  4. +9 −1 media/js/kpi.dashboard.js
View
@@ -174,26 +174,34 @@ class QuestionsResource(CachedResource):
"""
date = fields.DateField('date')
questions = fields.IntegerField('questions', default=0)
- responded = fields.IntegerField('responded', default=0)
+ responded_72 = fields.IntegerField('responded_72', default=0)
+ responded_24 = fields.IntegerField('responded_24', default=0)
solved = fields.IntegerField('solved', default=0)
def get_object_list(self, request):
# Set up the query for the data we need.
qs = _daily_qs_for(Question)
- # All answers tht were created within 3 days of the question.
- aq = Answer.objects.filter(
+ # All answers that were created within 3 days of the question.
+ aq_72 = Answer.objects.filter(
created__lt=F('question__created') + timedelta(days=3))
# Questions of said answers.
- rs = qs.filter(id__in=aq.values_list('question'))
+ rs_72 = qs.filter(id__in=aq_72.values_list('question'))
+
+ # All answers that were created within 24 hours of the question.
+ aq_24 = Answer.objects.filter(
+ created__lt=F('question__created') + timedelta(hours=24))
+ # Questions of said answers.
+ rs_24 = qs.filter(id__in=aq_24.values_list('question'))
# Questions with a solution.
qs_with_solutions = qs.exclude(solution_id=None)
return merge_results(
questions=qs,
solved=qs_with_solutions,
- responded=rs)
+ responded_72=rs_72,
+ responded_24=rs_24)
class Meta(object):
cache = SimpleCache()
@@ -26,10 +26,10 @@ <h1>{{ title }}</h1>
</li>
<li>
<p><strong>{% trans %}
- Questions responded to within 72 hours{% endtrans %}
+ Questions responded to within X hours{% endtrans %}
</strong></p>
<p>{% trans %}
- Definition: Percentage of questions that get an action within 72
+ Definition: Percentage of questions that get an action within X
hours{% endtrans %}
</p>
</li>
@@ -62,7 +62,8 @@ def test_questions(self):
r = self._get_api_result('kpi_questions')
eq_(r['objects'][0]['solved'], 1)
- eq_(r['objects'][0]['responded'], 2)
+ eq_(r['objects'][0]['responded_24'], 2)
+ eq_(r['objects'][0]['responded_72'], 2)
eq_(r['objects'][0]['questions'], 3)
def test_questions_inactive_user(self):
View
@@ -61,9 +61,17 @@ window.KpiDashboard = Backbone.View.extend({
ySuffix: '%',
yDecimals: 1
}
+ }, {
+ name: gettext('Responded in 24 hours'),
+ numerator: 'responded_24',
+ denominator: 'questions',
+ tooltip: {
+ ySuffix: '%',
+ yDecimals: 1
+ }
}, {
name: gettext('Responded in 72 hours'),
- numerator: 'responded',
+ numerator: 'responded_72',
denominator: 'questions',
tooltip: {
ySuffix: '%',

0 comments on commit b45a8f8

Please sign in to comment.