aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/proxy/state_impl/_operations
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-09-01 18:44:48 +0200
committerWojtek Kosior <koszko@koszko.org>2022-09-09 13:55:05 +0200
commit009ee56ccc8021e597c3fc5970a351b45a6d1ac7 (patch)
tree6cd46b7085263dc15bab2ad54990cefda24f3948 /src/hydrilla/proxy/state_impl/_operations
parentc163adccfe9db22bd1ba0888a3f60e1373c0a07a (diff)
downloadhaketilo-hydrilla-009ee56ccc8021e597c3fc5970a351b45a6d1ac7.tar.gz
haketilo-hydrilla-009ee56ccc8021e597c3fc5970a351b45a6d1ac7.zip
[proxy] make it possible to enable and disable mapping versions from web UI
Diffstat (limited to 'src/hydrilla/proxy/state_impl/_operations')
-rw-r--r--src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py28
1 files changed, 18 insertions, 10 deletions
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';
''',
)