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-28 12:54:55 +0200
commitd150d656bdab394f649a67490b146c5798361187 (patch)
tree4fef7b190cc4c5db625e06c5b0d76ca55bc3badd /src/hydrilla/proxy/state_impl/_operations
parentf2b91572b163099b29c940cf6fe5814a047fdc51 (diff)
downloadhaketilo-hydrilla-d150d656bdab394f649a67490b146c5798361187.tar.gz
haketilo-hydrilla-d150d656bdab394f649a67490b146c5798361187.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';
''',
)