def _migrate_report_filters(apps, schema_editor): """ Migrates ReportConfig filters with multiple values from CHOICE_DELIMITER-delimited strings to lists. """ key = ["name slug"] results = ReportConfig.get_db().view( "reportconfig/configs_by_domain", reduce=False, include_docs=True, startkey=key, endkey=key + [{}] ) count = 0 for result in results: dirty = False doc = result['doc'] config = ReportConfig.wrap(doc) for name, value in config['filters'].items(): if isinstance(value, str) and CHOICE_DELIMITER in value: print("Updating config {} filter {}".format(config._id, name)) config['filters'][name] = value.split(CHOICE_DELIMITER) dirty = True if dirty: count = count + 1 config.save() print("Updated {} configs".format(count))
def total(self): key = ["name", self.request.domain, self.request.couch_user._id] results = ReportConfig.get_db().view( 'reportconfig/configs_by_domain', include_docs=False, startkey=key, endkey=key + [{}], reduce=True, ).all() return results[0]['value'] if results else 0
def total(self): key = ["name", self.request.domain, self.request.couch_user._id] results = ReportConfig.get_db().view( 'reportconfig/configs_by_domain', include_docs=False, startkey=key, endkey=key+[{}], reduce=True, ).all() return results[0]['value'] if results else 0
def handle(self, report_slug, *args, **options): kwargs = {'stale': settings.COUCH_STALE_QUERY} key = ["name slug"] result = cache_core.cached_view( ReportConfig.get_db(), "reportconfig/configs_by_domain", reduce=False, include_docs=False, startkey=key, endkey=key + [{}], **kwargs) for report_config in result: domain, owner_id, slug = report_config['key'][1:4] if slug == report_slug: print("%s, %s, %s" % ( domain, owner_id, slug ))
def handle(self, report_slug, *args, **options): kwargs = {'stale': settings.COUCH_STALE_QUERY} key = ["name slug"] result = cache_core.cached_view( ReportConfig.get_db(), "reportconfig/configs_by_domain", reduce=False, include_docs=False, startkey=key, endkey=key + [{}], **kwargs) for report_config in result: domain, owner_id, slug = report_config['key'][1:4] if slug == report_slug: print("%s, %s, %s" % ( domain, owner_id, slug ))