i should have noticed this the first time i reviewed, but this is not ok (will iterate through every case in the domain and load them all into memory). we should use `iter_docs` at the very least (https://github.com/dimagi/dimagi-utils/blob/7b6aa5a741a3d293d4044fdfa454b7262235c84c/dimagi/utils/couch/database.py#L50) and probably better to look into a way to do the aggregation in couch or elastic search.