Skip to content

Commit

Permalink
Merge pull request #5193 from dimagi/fix-active-mobile-users
Browse files Browse the repository at this point in the history
restrict users who submitted forms by domain in 'Active Mobile Users (last 30 days)'
  • Loading branch information
twymer committed Jan 2, 2015
2 parents ffb301f + 5bda831 commit 596aa4b
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions corehq/apps/hqadmin/reporting/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,22 @@ def get_active_users_data(domains, datespan, interval, datefield='date',
if additional_params_es:
sms_query = add_params_to_query(sms_query, additional_params_es)
users = {u['term'] for u in sms_query.run().facet('users', "terms")}

if include_forms:
users |= {u['term'] for u in FormES()
.user_facet(size=USER_COUNT_UPPER_BOUND)
.submitted(gte=f, lte=t)
.size(0)
.run()
.facets.user.result}

users |= {
u['term'] for u in FormES()
.user_facet(size=USER_COUNT_UPPER_BOUND)
.submitted(gte=f, lte=t)
.size(0)
.run()
.facets.user.result
if u['term'] in (
UserES()
.show_inactive()
.mobile_users()
.domain(domains)
.run().doc_ids
)
}
c = len(users)
if c > 0:
histo_data.append(get_data_point(c, timestamp))
Expand Down

0 comments on commit 596aa4b

Please sign in to comment.