def finish_handle(self): filepath = os.path.join(settings.FILEPATH,'corehq','pillows','mappings','fullxform_mapping.py') full_xform_pillow = FullXFormPillow(create_index=False) #current index #check current index aliased_indices = full_xform_pillow.check_alias() # current_index = '%s_%s' % (xform_pillow.es_index_prefix, xform_pillow.calc_meta()) current_index = full_xform_pillow.es_index sys.stderr.write("current index:\n") sys.stderr.write('XFORM_INDEX="%s"\n' % current_index) #regenerate the mapping dict mapping = xform_mapping.XFORM_MAPPING full_xform_pillow.default_mapping = mapping delattr(full_xform_pillow, '_calc_meta_cache') calc_index = "%s_%s" % (full_xform_pillow.es_index_prefix, full_xform_pillow.calc_meta()) if calc_index not in aliased_indices and calc_index != current_index: sys.stderr.write("\n\tWarning, current index %s is not aliased at the moment\n" % current_index) sys.stderr.write("\tCurrent live aliased index: %s\n\n" % (','.join(aliased_indices))) if calc_index != current_index: sys.stderr.write("FULL_XFORM_INDEX hash has changed, please update \n\t%s\n\tXFORM_INDEX property with the line below:\n" % filepath) sys.stdout.write('FULL_XFORM_INDEX="%s"\n' % calc_index) else: sys.stderr.write("FULL_XFORM_INDEX unchanged\n")
def full_couch_view_iter(self): view_kwargs = {} dynamic_domains = FullXFormPillow.load_domains().keys() for domain in dynamic_domains: start_seq = 0 view_kwargs["startkey"] = [domain] view_kwargs['endkey'] = [domain, {}] view_kwargs.update(self.get_extra_view_kwargs()) view_chunk = self.db.view( self.view_name, reduce=False, limit=self.chunk_size * self.chunk_size, skip=start_seq, **view_kwargs ) while len(view_chunk) > 0: for item in view_chunk: yield item start_seq += self.chunk_size * self.chunk_size view_chunk = self.db.view(self.view_name, reduce=False, limit=self.chunk_size * self.chunk_size, skip=start_seq, **view_kwargs )