From d516b9decad07b940b3cd117fc4e353dd8bbe7d2 Mon Sep 17 00:00:00 2001
From: Wojtek Kosior <koszko@koszko.org>
Date: Wed, 24 Aug 2022 10:47:33 +0200
Subject: make repo packages (mappings) load as uninstalled; make them
 installable through the web UI

---
 src/hydrilla/proxy/tables.sql | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

(limited to 'src/hydrilla/proxy/tables.sql')

diff --git a/src/hydrilla/proxy/tables.sql b/src/hydrilla/proxy/tables.sql
index 3b84741..aa98081 100644
--- a/src/hydrilla/proxy/tables.sql
+++ b/src/hydrilla/proxy/tables.sql
@@ -241,7 +241,7 @@ SELECT
 	i.item_id, i.identifier,
         CASE WHEN
                 ms.enabled = 'N' AND
-		(ms.required OR COUNT(p.payload_id) > 0)
+		COALESCE(ms.active_version_id, -1) = iv.item_version_id
         THEN
                 'A' -- AUTO_ENABLED mapping
         ELSE
@@ -260,18 +260,10 @@ FROM
                 USING (item_id)
 	JOIN      item_versions    AS iv
 	        USING (item_id)
-        LEFT JOIN payloads         AS p
-                ON iv.item_version_id = p.mapping_item_id
         JOIN      repo_iterations  AS ri
                 USING (repo_iteration_id)
         JOIN      repos            AS r
-                USING (repo_id)
-WHERE
-        i.type = 'M'
-GROUP BY
-        ms.enabled, ms.required, ms.active_version_id,
-        iv.item_version_id, iv.definition, iv.installed,
-        r.repo_id, r.active_iteration_id, r.name, ri.iteration;
+                USING (repo_id);
 
 CREATE TABLE resolved_depended_resources(
         payload_id       INTEGER,
-- 
cgit v1.2.3

