SMQ-2865 - Fix listing indirect groups and group related listing of channels and clients (#2976)

Signed-off-by: Felix Gateru <felix.gateru@gmail.com>
This commit is contained in:
Felix Gateru
2025-07-04 18:33:58 +03:00
committed by GitHub
parent a0044c51be
commit 0a18a580eb
3 changed files with 33 additions and 9 deletions
+3
View File
@@ -696,10 +696,13 @@ direct_groups_with_subgroup AS (
"groups" g ON g.id = gr.entity_id
JOIN
groups_role_actions all_actions ON all_actions.role_id = grm.role_id
LEFT JOIN "groups" g2
ON g2.path <@ g.path AND nlevel(g2.path) = nlevel(g.path) + 1
WHERE
grm.member_id = '%s'
AND g.domain_id = '%s'
AND gra."action" LIKE 'subgroup_channel%%'
AND g2.path IS NULL
GROUP BY
gr.entity_id, grm.member_id, gr.id, gr."name", g."path", g.id
),
+3
View File
@@ -721,10 +721,13 @@ func (repo *clientRepo) userClientBaseQuery(domainID, userID string) string {
"groups" g ON g.id = gr.entity_id
JOIN
groups_role_actions all_actions ON all_actions.role_id = grm.role_id
LEFT JOIN "groups" g2
ON g2.path <@ g.path AND nlevel(g2.path) = nlevel(g.path) + 1
WHERE
grm.member_id = '%s'
AND g.domain_id = '%s'
AND gra."action" LIKE 'subgroup_client%%'
AND g2.path IS NULL
GROUP BY
gr.entity_id, grm.member_id, gr.id, gr."name", g."path", g.id
),
+27 -9
View File
@@ -942,17 +942,35 @@ GROUP BY
),
direct_groups_with_subgroup AS (
SELECT
*
FROM direct_groups
WHERE EXISTS (
SELECT 1
FROM unnest(direct_groups.actions) AS action
WHERE action LIKE 'subgroup_%%'
)
g.*,
gr.entity_id AS entity_id,
grm.member_id AS member_id,
gr.id AS role_id,
gr."name" AS role_name,
array_agg(DISTINCT all_actions."action") AS actions
FROM
groups_role_members grm
JOIN
groups_role_actions gra ON gra.role_id = grm.role_id
JOIN
groups_roles gr ON gr.id = grm.role_id
JOIN
"groups" g ON g.id = gr.entity_id
JOIN
groups_role_actions all_actions ON all_actions.role_id = grm.role_id
LEFT JOIN "groups" g2
ON g2.path <@ g.path AND nlevel(g2.path) = nlevel(g.path) + 1
WHERE
grm.member_id = '%s'
AND g.domain_id = '%s'
AND gra."action" LIKE 'subgroup_%%'
AND g2.path IS NULL
GROUP BY
gr.entity_id, grm.member_id, gr.id, gr."name", g."path", g.id
),
indirect_child_groups AS (
SELECT
DISTINCT indirect_child_groups.id as child_id,
DISTINCT indirect_child_groups.id as child_id,
indirect_child_groups.*,
dgws.id as access_provider_id,
dgws.role_id as access_provider_role_id,
@@ -1087,7 +1105,7 @@ final_groups AS (
GROUP BY
dg.id, d.id, dr.id
)
`, userID, domainID, domainID, userID, domainID)
`, userID, domainID, userID, domainID, domainID, userID, domainID)
}
func buildQuery(gm groups.PageMeta, ids ...string) string {