Show also same items from page 0

This commit is contained in:
Jan Kvetina 2022-03-03 17:03:50 +01:00
parent fa94d858d7
commit 396ecb90b7

View File

@ -4,26 +4,49 @@ WITH x AS (
app.get_app_id() AS app_id,
app.get_item('$PAGE_ID') AS page_id
FROM DUAL
),
t AS (
SELECT
t.item_type,
t.item_name,
t.page_id,
t.value_en
FROM translations_extracts t
JOIN x
ON (x.page_id IN (0, t.page_id) OR x.page_id IS NULL)
LEFT JOIN translated_items i
ON i.app_id = x.app_id
AND i.page_id = t.page_id
AND i.item_name = t.item_name
LEFT JOIN translated_items g
ON g.app_id = x.app_id
AND g.page_id = 0
AND g.item_name = t.item_name
AND g.value_en = t.value_en
WHERE 1 = 1
AND i.item_name IS NULL
AND g.item_name IS NULL
AND t.is_translated IS NULL
)
SELECT
t.item_type,
t.item_name,
t.page_id,
t.value_en
FROM translations_extracts t
FROM t
UNION ALL
--
SELECT
REGEXP_SUBSTR(t.item_name, '^([^_]+)', 1, 1, NULL, 1) AS item_type,
--
i.item_name,
i.page_id,
i.value_en
FROM translated_items i
JOIN x
ON (x.page_id IN (0, t.page_id) OR x.page_id IS NULL)
LEFT JOIN translated_items i
ON i.app_id = x.app_id
AND i.page_id = t.page_id
AND i.item_name = t.item_name
LEFT JOIN translated_items g
ON g.app_id = x.app_id
AND g.page_id = 0
AND g.item_name = t.item_name
AND g.value_en = t.value_en
WHERE 1 = 1
AND i.item_name IS NULL
AND g.item_name IS NULL
AND t.is_translated IS NULL;
ON x.app_id = i.app_id
AND x.page_id != i.page_id
JOIN t
ON t.item_name = i.item_name
WHERE i.item_name NOT IN ('PAGE_NAME');