Beispiel #1
0
    def get_doc_ids(self, domain):
        from corehq.apps.users.dbaccessors.all_commcare_users import get_all_user_ids_by_domain
        from corehq.apps.users.models import CommCareUser
        from corehq.apps.users.models import WebUser
        if self.include_mobile_users:
            user_ids = get_all_user_ids_by_domain(
                domain, include_web_users=False, include_mobile_users=True
            )
            yield CommCareUser, list(user_ids)

        if self.include_web_users:
            user_ids = get_all_user_ids_by_domain(
                domain, include_web_users=True, include_mobile_users=False
            )
            yield WebUser, list(user_ids)
Beispiel #2
0
    def get_doc_ids(self, domain):
        from corehq.apps.users.dbaccessors.all_commcare_users import get_all_user_ids_by_domain
        from corehq.apps.users.models import CommCareUser
        from corehq.apps.users.models import WebUser
        if self.include_mobile_users:
            user_ids = get_all_user_ids_by_domain(domain,
                                                  include_web_users=False,
                                                  include_mobile_users=True)
            yield CommCareUser, list(user_ids)

        if self.include_web_users:
            user_ids = get_all_user_ids_by_domain(domain,
                                                  include_web_users=True,
                                                  include_mobile_users=False)
            yield WebUser, list(user_ids)
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
Beispiel #4
0
 def get_filters(self, domain_name):
     """
     :return: A generator of filters each filtering for at most 1000 users.
     """
     from corehq.apps.users.dbaccessors.all_commcare_users import get_all_user_ids_by_domain
     user_ids = get_all_user_ids_by_domain(domain_name, include_web_users=self.include_web_users)
     for chunk in chunked(user_ids, 1000):
         query_kwarg = '{}__in'.format(self.user_id_field)
         yield Q(**{query_kwarg: chunk})
Beispiel #5
0
 def get_filters(self, domain_name):
     """
     :return: A generator of filters each filtering for at most 1000 users.
     """
     from corehq.apps.users.dbaccessors.all_commcare_users import get_all_user_ids_by_domain
     user_ids = get_all_user_ids_by_domain(domain_name, include_web_users=self.include_web_users)
     for chunk in chunked(user_ids, 1000):
         query_kwarg = '{}__in'.format(self.user_id_field)
         yield Q(**{query_kwarg: chunk})
Beispiel #6
0
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_doc_ids(self, domain):
     from corehq.apps.users.dbaccessors.all_commcare_users import get_all_user_ids_by_domain
     from casexml.apps.phone.models import SyncLog
     for user_id in get_all_user_ids_by_domain(domain):
         rows = SyncLog.view(
             "phone/sync_logs_by_user",
             startkey=[user_id],
             endkey=[user_id, {}],
             reduce=False,
             include_docs=False,
         )
         yield SyncLog, [row['id'] for row in rows]
Beispiel #8
0
 def get_doc_ids(self, domain):
     from corehq.apps.users.dbaccessors.all_commcare_users import get_all_user_ids_by_domain
     from casexml.apps.phone.models import SyncLog
     for user_id in get_all_user_ids_by_domain(domain):
         # this excludes sync logs in old DB (prior to migration to synclog DB). See ``synclog_view``.
         rows = SyncLog.view(
             "phone/sync_logs_by_user",
             startkey=[user_id],
             endkey=[user_id, {}],
             reduce=False,
             include_docs=False,
         )
         yield SyncLog, [row['id'] for row in rows]
def _compare_users(domain, doc_type):
    include_web_users = doc_type == 'WebUser'
    if not include_web_users and 'Deleted' in doc_type:
        # deleted users = all users - non-deleted users
        all_mobile_user_ids = set(
            get_doc_ids_in_domain_by_class(domain, CommCareUser))
        non_deleted_mobile_user_ids = get_mobile_user_ids(domain)
        couch_count = all_mobile_user_ids - non_deleted_mobile_user_ids
    else:
        couch_count = set(
            get_all_user_ids_by_domain(
                domain,
                include_web_users=include_web_users,
                include_mobile_users=not include_web_users))
    return _get_diffs(couch_count, get_es_user_ids(domain, doc_type))
Beispiel #10
0
def _compare_users(domain, doc_type, startdate, enddate):
    if startdate or enddate:
        raise CommandError("Date filtering not supported for users")

    include_web_users = doc_type == 'WebUser'
    if not include_web_users and 'Deleted' in doc_type:
        # deleted users = all users - non-deleted users
        all_mobile_user_ids = set(
            get_doc_ids_in_domain_by_class(domain, CommCareUser))
        non_deleted_mobile_user_ids = get_mobile_user_ids(domain)
        couch_count = all_mobile_user_ids - non_deleted_mobile_user_ids
    else:
        couch_count = set(
            get_all_user_ids_by_domain(
                domain,
                include_web_users=include_web_users,
                include_mobile_users=not include_web_users))
    return _get_diffs(couch_count, get_es_user_ids(domain, doc_type))
Beispiel #11
0
def _compare_users(domain, doc_type, startdate, enddate):
    if startdate or enddate:
        raise CommandError("Date filtering not supported for users")

    include_web_users = doc_type == 'WebUser'
    if not include_web_users and 'Deleted' in doc_type:
        # deleted users = all users - non-deleted users
        all_mobile_user_ids = set(get_doc_ids_in_domain_by_class(domain, CommCareUser))
        non_deleted_mobile_user_ids = get_mobile_user_ids(domain)
        couch_count = all_mobile_user_ids - non_deleted_mobile_user_ids
    else:
        couch_count = set(get_all_user_ids_by_domain(
            domain,
            include_web_users=include_web_users,
            include_mobile_users=not include_web_users)
        )
    return _get_diffs(
        couch_count,
        get_es_user_ids(domain, doc_type)
    )
Beispiel #12
0
 def get_ids(self, domain_name):
     from corehq.apps.users.dbaccessors.all_commcare_users import get_all_user_ids_by_domain
     return get_all_user_ids_by_domain(
         domain_name, include_web_users=self.include_web_users)