Skip to content

Commit

Permalink
Merge pull request #154 from rapidpro/case_count_tweaks
Browse files Browse the repository at this point in the history
Case count tweaks
  • Loading branch information
rowanseymour committed Sep 28, 2016
2 parents 7500cec + 81788c4 commit 75a9443
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 9 additions & 2 deletions casepro/statistics/migrations/0008_existing_case_stats_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ def calculate_totals_for_cases(apps, schema_editor):
CaseAction = apps.get_model('cases', 'CaseAction')
DailyCount = apps.get_model('statistics', 'DailyCount')

qs = Case.objects.all().order_by('id')
for case in qs:
cases = list(Case.objects.all().order_by('id'))
num_updated = 0

for case in cases:
open_action = case.actions.filter(action='O').first()
org = open_action.case.org
user = open_action.created_by
Expand All @@ -32,6 +34,11 @@ def calculate_totals_for_cases(apps, schema_editor):
count=1)
DailyCount.objects.create(day=day, item_type='D',
scope='partner:%d' % close_action.case.assignee.pk, count=1)

num_updated += 1
if num_updated % 100 == 0:
print("Created daily counts for %d of %d cases" % (num_updated, len(cases)))

except CaseAction.DoesNotExist:
# no close action means to close totals to count for this case
pass
Expand Down
6 changes: 3 additions & 3 deletions templates/orgs_ext/org_home.haml
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@
%th
- trans "Total replies"
%th
- trans "Cases Opened this month"
- trans "Cases opened this month"
%th
- trans "Cases Closed this month"
- trans "Cases closed this month"
%th
- trans "Total Cases opened"
- trans "Total cases opened"
%tbody
%tr{ ng-repeat:"user in users" }
%td
Expand Down

0 comments on commit 75a9443

Please sign in to comment.