perf: lookup
Co-Authored-By: alifurkanstahl <180474740+alifurkanstahl@users.noreply.github.com>
This commit is contained in:
co-authored by
alifurkanstahl
parent
2376258f02
commit
7eae377c01
@@ -34,17 +34,17 @@ def get_sorted_filter_ids(request, model: dict, enabled_filter_ids: list = None)
|
|||||||
if 'info' in model and 'meta' in model['info']:
|
if 'info' in model and 'meta' in model['info']:
|
||||||
filter_ids.extend(model['info']['meta'].get('filterIds', []))
|
filter_ids.extend(model['info']['meta'].get('filterIds', []))
|
||||||
filter_ids = list(set(filter_ids))
|
filter_ids = list(set(filter_ids))
|
||||||
active_filter_ids = [function.id for function in Functions.get_functions_by_type('filter', active_only=True)]
|
active_filter_ids = {function.id for function in Functions.get_functions_by_type('filter', active_only=True)}
|
||||||
|
|
||||||
def get_active_status(filter_id):
|
def get_active_status(filter_id):
|
||||||
function_module = get_function_module(request, filter_id)
|
function_module = get_function_module(request, filter_id)
|
||||||
|
|
||||||
if getattr(function_module, 'toggle', None):
|
if getattr(function_module, 'toggle', None):
|
||||||
return filter_id in (enabled_filter_ids or [])
|
return filter_id in (enabled_filter_ids or set())
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
active_filter_ids = [filter_id for filter_id in active_filter_ids if get_active_status(filter_id)]
|
active_filter_ids = {filter_id for filter_id in active_filter_ids if get_active_status(filter_id)}
|
||||||
|
|
||||||
filter_ids = [fid for fid in filter_ids if fid in active_filter_ids]
|
filter_ids = [fid for fid in filter_ids if fid in active_filter_ids]
|
||||||
filter_ids.sort(key=lambda fid: (get_priority(fid), fid))
|
filter_ids.sort(key=lambda fid: (get_priority(fid), fid))
|
||||||
|
|||||||
@@ -130,11 +130,11 @@ async def get_all_models(request, refresh: bool = False, user: UserModel = None)
|
|||||||
]
|
]
|
||||||
models = models + arena_models
|
models = models + arena_models
|
||||||
|
|
||||||
global_action_ids = [function.id for function in Functions.get_global_action_functions()]
|
global_action_ids = {function.id for function in Functions.get_global_action_functions()}
|
||||||
enabled_action_ids = [function.id for function in Functions.get_functions_by_type('action', active_only=True)]
|
enabled_action_ids = {function.id for function in Functions.get_functions_by_type('action', active_only=True)}
|
||||||
|
|
||||||
global_filter_ids = [function.id for function in Functions.get_global_filter_functions()]
|
global_filter_ids = {function.id for function in Functions.get_global_filter_functions()}
|
||||||
enabled_filter_ids = [function.id for function in Functions.get_functions_by_type('filter', active_only=True)]
|
enabled_filter_ids = {function.id for function in Functions.get_functions_by_type('filter', active_only=True)}
|
||||||
|
|
||||||
custom_models = Models.get_all_models()
|
custom_models = Models.get_all_models()
|
||||||
|
|
||||||
@@ -328,14 +328,14 @@ async def get_all_models(request, refresh: bool = False, user: UserModel = None)
|
|||||||
for model in models:
|
for model in models:
|
||||||
action_ids = [
|
action_ids = [
|
||||||
action_id
|
action_id
|
||||||
for action_id in list(set(model.pop('action_ids', []) + global_action_ids))
|
for action_id in set(model.pop('action_ids', [])) | global_action_ids
|
||||||
if action_id in enabled_action_ids
|
if action_id in enabled_action_ids
|
||||||
]
|
]
|
||||||
action_ids.sort(key=lambda aid: (get_action_priority(aid), aid))
|
action_ids.sort(key=lambda aid: (get_action_priority(aid), aid))
|
||||||
|
|
||||||
filter_ids = [
|
filter_ids = [
|
||||||
filter_id
|
filter_id
|
||||||
for filter_id in list(set(model.pop('filter_ids', []) + global_filter_ids))
|
for filter_id in set(model.pop('filter_ids', [])) | global_filter_ids
|
||||||
if filter_id in enabled_filter_ids
|
if filter_id in enabled_filter_ids
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user