Ejemplo n.º 1
0
def get_couch_domain_case_change_provider(domain):
    return CouchViewChangeProvider(couch_db=CommCareCase.get_db(),
                                   view_name='cases_by_owner/view',
                                   chunk_size=100,
                                   view_kwargs={
                                       'include_docs': True,
                                       'startkey': [domain],
                                       'endkey': [domain, {}, {}]
                                   })
Ejemplo n.º 2
0
 def build(self):
     return ElasticPillowReindexer(pillow=get_user_pillow(),
                                   change_provider=CouchViewChangeProvider(
                                       couch_db=CommCareUser.get_db(),
                                       view_name='users/by_username',
                                       view_kwargs={
                                           'include_docs': True,
                                       }),
                                   elasticsearch=get_es_new(),
                                   index_info=USER_INDEX_INFO,
                                   **self.options)
Ejemplo n.º 3
0
 def build(self):
     return PillowChangeProviderReindexer(
         pillow_or_processor=get_group_to_user_pillow(),
         change_provider=CouchViewChangeProvider(
             couch_db=Group.get_db(),
             view_name='all_docs/by_doc_type',
             view_kwargs={
                 'startkey': ['Group'],
                 'endkey': ['Group', {}],
                 'include_docs': True,
             }),
     )
Ejemplo n.º 4
0
 def build(self):
     return ElasticPillowReindexer(pillow=get_group_pillow(),
                                   change_provider=CouchViewChangeProvider(
                                       couch_db=Group.get_db(),
                                       view_name='all_docs/by_doc_type',
                                       view_kwargs={
                                           'startkey': ['Group'],
                                           'endkey': ['Group', {}],
                                           'include_docs': True,
                                       }),
                                   elasticsearch=get_es_new(),
                                   index_info=GROUP_INDEX_INFO,
                                   **self.options)
Ejemplo n.º 5
0
 def build(self):
     return ElasticPillowReindexer(
         pillow_or_processor=get_domain_kafka_to_elasticsearch_pillow(),
         change_provider=CouchViewChangeProvider(
             couch_db=Domain.get_db(),
             view_name='all_docs/by_doc_type',
             view_kwargs={
                 'startkey': ['Domain'],
                 'endkey': ['Domain', {}],
                 'include_docs': True,
             }),
         elasticsearch=get_es_new(),
         index_info=DOMAIN_INDEX_INFO,
         **self.options)
Ejemplo n.º 6
0
def check_domain(domain, num_cases=1000, randomization=100):
    form_db = dbaccessors.FormAccessors(domain)

    case_iterator = CouchViewChangeProvider(
        couch_db=CommCareCase.get_db(),
        view_name='by_domain_doc_type_date/view',
        view_kwargs={
            'startkey': [domain, 'CommCareCase'],
            'endkey': [domain, 'CommCareCase', {}],
            'include_docs': False,
        }).iter_all_changes()

    for i in with_progress_bar(range(0, num_cases), oneline=False):
        skips = random.randint(1, randomization)
        for _ in range(0, skips):
            case = next(case_iterator)

        current_case = CommCareCase(case.get_document())
        case_id, diffs = is_problem_case(current_case, form_db)
        if case_id:
            print("%s: diffs" % case_id)
            for diff in diffs:
                print(diff)