def obj_get_list(self, bundle, domain, **kwargs): filters = v0_3.CaseListFilters(bundle.request.GET).filters # Since tastypie handles the "from" and "size" via slicing, we have to wipe them out here # since ElasticCaseQuery adds them. I believe other APIs depend on the behavior of ElasticCaseQuery # hence I am not modifying that query = ElasticCaseQuery(domain, filters).get_query() if 'from' in query: del query['from'] if 'size' in query: del query['size'] return ESQuerySet(payload = query, model = CommCareCase, es_client = self.case_es(domain)).order_by('server_modified_on') # Not that CaseES is used only as an ES client, for `run_query` against the proper index
def _get_case_mock(project, params): # this is mostly copy/paste/modified from CommCareCaseResource filters = CaseListFilters(params).filters query = ElasticCaseQuery(project, filters).get_query() if 'from' in query: del query['from'] if 'size' in query: del query['size'] query_set = ElasticAPIQuerySet( payload=query, model=ESCase, es_client=CaseES(project), ).order_by('server_modified_on') return MockApi(query_set, CommCareCaseResource(), CommCareCaseSerializer())
def obj_get_list(self, bundle, domain, **kwargs): filters = v0_3.CaseListFilters(bundle.request.GET).filters # Since tastypie handles the "from" and "size" via slicing, we have to wipe them out here # since ElasticCaseQuery adds them. I believe other APIs depend on the behavior of ElasticCaseQuery # hence I am not modifying that query = ElasticCaseQuery(domain, filters).get_query() if 'from' in query: del query['from'] if 'size' in query: del query['size'] return ESQuerySet( payload=query, model=lambda jvalue: dict_object( CommCareCase.wrap(jvalue).get_json()), es_client=CaseES(domain) ) # Not that XFormES is used only as an ES client, for `run_query` against the proper index
def obj_get_list(self, bundle, domain, **kwargs): """ Overridden to wrap the case JSON from ElasticSearch with the custom.hope.case.HOPECase class """ filters = v0_3.CaseListFilters(bundle.request.GET).filters # Since tastypie handles the "from" and "size" via slicing, we have to wipe them out here # since ElasticCaseQuery adds them. I believe other APIs depend on the behavior of ElasticCaseQuery # hence I am not modifying that query = ElasticCaseQuery(domain, filters).get_query() if 'from' in query: del query['from'] if 'size' in query: del query['size'] # Note that CaseES is used only as an ES client, for `run_query` against the proper index return ElasticAPIQuerySet( payload=query, model=HOPECase, es_client=self.case_es(domain), ).order_by('server_modified_on')