From d150d656bdab394f649a67490b146c5798361187 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Thu, 1 Sep 2022 18:44:48 +0200 Subject: [proxy] make it possible to enable and disable mapping versions from web UI --- .../_operations/recompute_dependencies.py | 28 ++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'src/hydrilla/proxy/state_impl/_operations') diff --git a/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py b/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py index 5403ec3..9419f91 100644 --- a/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py +++ b/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py @@ -49,21 +49,26 @@ AnyInfoVar = t.TypeVar( def _get_infos_of_type(cursor: sqlite3.Cursor, info_type: t.Type[AnyInfoVar],) \ -> t.Mapping[int, AnyInfoVar]: + join_mapping_statuses = 'JOIN mapping_statuses AS ms USING (item_id)' + condition = "i.type = 'M' AND ms.enabled != 'D'" + if info_type is item_infos.ResourceInfo: + join_mapping_statuses = '' + condition = "i.type = 'R'" + cursor.execute( - ''' + f''' SELECT ive.item_version_id, ive.definition, ive.repo, ive.repo_iteration FROM - item_versions_extra AS ive - JOIN items AS i USING (item_id) - LEFT JOIN mapping_statuses AS ms USING (item_id) + item_versions_extra AS ive + JOIN items AS i USING (item_id) + {join_mapping_statuses} WHERE - i.type = ? AND COALESCE(ms.enabled != 'D', TRUE); - ''', - (info_type.type.value[0].upper(),) + {condition}; + ''' ) result: dict[int, AnyInfoVar] = {} @@ -92,11 +97,14 @@ def _get_current_required_state( cursor.execute( ''' SELECT - definition, repo, repo_iteration + ive.definition, ive.repo, ive.repo_iteration FROM - item_versions_extra + item_versions_extra AS ive + JOIN items AS i USING (item_id) WHERE - item_id NOT IN __unlocked_ids AND active = 'R'; + i.type = 'M' AND + item_id NOT IN __unlocked_ids AND + ive.active = 'R'; ''', ) -- cgit v1.2.3