Skip to content

Commit

Permalink
Take review suggestions into account
Browse files Browse the repository at this point in the history
  • Loading branch information
jhrozek committed Jul 7, 2024
1 parent d1f9ae6 commit 9fc10da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions database/query/profiles.sql
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ SELECT * FROM profiles WHERE lower(name) = lower(sqlc.arg(name)) AND project_id
-- name: ListProfilesByProjectID :many
WITH helper AS(
SELECT pr.id as profid,
ARRAY_AGG(ROW(ps.id, ps.profile_id, ps.entity, ps.selector, ps.comment)::profile_selector) FILTER (WHERE ps.id IS NOT NULL) AS selectors
ARRAY_AGG(ROW(ps.id, ps.profile_id, ps.entity, ps.selector, ps.comment)::profile_selector) AS selectors
FROM profiles pr
LEFT JOIN profile_selectors ps
JOIN profile_selectors ps
ON pr.id = ps.profile_id
WHERE pr.project_id = $1
GROUP BY pr.id
Expand All @@ -78,15 +78,15 @@ SELECT
helper.selectors::profile_selector[] AS profiles_with_selectors
FROM profiles
JOIN profiles_with_entity_profiles ON profiles.id = profiles_with_entity_profiles.profid
JOIN helper ON profiles.id = helper.profid
LEFT JOIN helper ON profiles.id = helper.profid
WHERE profiles.project_id = $1;

-- name: ListProfilesByProjectIDAndLabel :many
WITH helper AS(
SELECT pr.id as profid,
ARRAY_AGG(ROW(ps.id, ps.profile_id, ps.entity, ps.selector, ps.comment)::profile_selector) FILTER (WHERE ps.id IS NOT NULL) AS selectors
ARRAY_AGG(ROW(ps.id, ps.profile_id, ps.entity, ps.selector, ps.comment)::profile_selector) AS selectors
FROM profiles pr
LEFT JOIN profile_selectors ps
JOIN profile_selectors ps
ON pr.id = ps.profile_id
WHERE pr.project_id = $1
GROUP BY pr.id
Expand All @@ -96,7 +96,7 @@ SELECT sqlc.embed(profiles),
helper.selectors::profile_selector[] AS profiles_with_selectors
FROM profiles
JOIN profiles_with_entity_profiles ON profiles.id = profiles_with_entity_profiles.profid
JOIN helper ON profiles.id = helper.profid
LEFT JOIN helper ON profiles.id = helper.profid
WHERE profiles.project_id = $1
AND (
-- the most common case first, if the include_labels is empty, we list profiles with no labels
Expand Down
12 changes: 6 additions & 6 deletions internal/db/profiles.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9fc10da

Please sign in to comment.