Skip to content

Commit

Permalink
use defaultdict
Browse files Browse the repository at this point in the history
  • Loading branch information
zandre-eng committed Dec 13, 2024
1 parent 7ec4e5b commit 25d9dc5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions corehq/apps/hqadmin/reports.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collections import defaultdict
from datetime import datetime, timedelta

from django.urls import reverse
Expand Down Expand Up @@ -534,7 +535,7 @@ def rows(self):

def _aggregate_case_count_data(self):
end_date = datetime.now() - timedelta(days=self.STALE_DATE_THRESHOLD_DAYS)
agg_res = {}
agg_res = defaultdict(lambda: 0)
curr_backoff_count = 0
curr_agg_date_range = self.AGG_DATE_RANGE
domains = self._get_domains()
Expand Down Expand Up @@ -568,8 +569,6 @@ def _aggregate_case_count_data(self):

def _merge_agg_data(self, agg_res, query_res):
for domain, case_count in query_res.items():
if domain not in agg_res:
agg_res[domain] = 0
agg_res[domain] += case_count

def _stale_case_count_in_date_range(self, domains, start_date, end_date):
Expand Down

0 comments on commit 25d9dc5

Please sign in to comment.