def _compare_mobile_users(domain, doc_type): couch_ids = set(get_all_user_ids_by_domain(domain, include_web_users=False)) es_ids = set(es.UserES().remove_default_filter('active').filter( es.filters.term('domain', domain)).get_ids()) return couch_ids - es_ids
def get_es_user_ids(domain, doc_type): return set( es.UserES() .remove_default_filters() .filter(es.users.domain(domain)) .filter(es.filters.doc_type(doc_type)) .filter(_get_user_base_doc_filter(doc_type)) .get_ids() )
def get_es_user_counts_by_doc_type(domain): agg = aggregations.TermsAggregation('doc_type', 'doc_type').aggregation( aggregations.TermsAggregation('base_doc', 'base_doc')) doc_type_buckets = (es.UserES().remove_default_filters().filter( es.users.domain(domain)).aggregation(agg).size( 0).run().aggregations.doc_type.buckets_dict) counts = Counter() for doc_type, bucket in doc_type_buckets.items(): for base_doc, count in bucket.base_doc.counts_by_bucket().items(): deleted = base_doc.endswith('deleted') if deleted: doc_type += '-Deleted' counts[doc_type] = count return counts