def get_downstream_app_id_map(downstream_domain, use_upstream_app_id=True): """ :param downstream_domain: domain name :param use_upstream_app_id: whether to search for downstream app based on upstream_app_id or family_id DEPRECATED: family_id is deprecated and will be removed. If calling this method, try to use upstream_app_id """ attr_to_search_on = "upstream_app_id" if use_upstream_app_id else "family_id" downstream_app_ids = defaultdict(list) for doc in get_brief_app_docs_in_domain(downstream_domain): if doc.get(attr_to_search_on): downstream_app_ids[doc[attr_to_search_on]].append(doc["_id"]) return downstream_app_ids
def _replace_master_app_ids(linked_domain, datasource_json): master_app_to_linked_app = { doc['family_id']: doc['_id'] for doc in get_brief_app_docs_in_domain(linked_domain) if doc.get('family_id', None) is not None } configured_filter = json.dumps(datasource_json['configured_filter']) for master_app_id, linked_app_id in master_app_to_linked_app.items(): configured_filter = configured_filter.replace(master_app_id, linked_app_id) datasource_json['configured_filter'] = json.loads(configured_filter) named_filters = json.dumps(datasource_json['named_filters']) for master_app_id, linked_app_id in master_app_to_linked_app.items(): named_filters = named_filters.replace(master_app_id, linked_app_id) datasource_json['named_filters'] = json.loads(named_filters)
def brief_apps(request, domain): return JsonResponse({ 'brief_apps': get_brief_app_docs_in_domain(domain, include_remote=False) })
def _get_downstream_app_id_map(downstream_domain): downstream_app_ids = defaultdict(list) for doc in get_brief_app_docs_in_domain(downstream_domain): if doc.get("family_id"): downstream_app_ids[doc["family_id"]].append(doc["_id"]) return downstream_app_ids
def get_master_app_to_linked_app(domain): return { doc["family_id"]: doc["_id"] for doc in get_brief_app_docs_in_domain(domain) if doc.get("family_id", None) is not None }