Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHI-2936: target profiles optimisation cherry pick #739

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions hrm-domain/hrm-core/profile/sql/profile-get-sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ export const getProfilesSqlBase = (selectTargetProfilesQuery: string) => `
FROM TargetProfiles profile
LEFT JOIN "ProfileSections" pps ON pps."profileId" = profile.id AND pps."accountSid" = profile."accountSid"
GROUP BY pps."profileId"
),

HasRelatedContacts AS (
SELECT COUNT(*) > 0 as "hasContacts", "profileId" FROM "Contacts" GROUP BY "profileId"
)

SELECT
Expand All @@ -77,7 +73,7 @@ export const getProfilesSqlBase = (selectTargetProfilesQuery: string) => `
LEFT JOIN RelatedProfileFlags rpf ON profiles.id = rpf."profileId"
LEFT JOIN RelatedProfileSections rps ON profiles.id = rps."profileId"
-- Remove this hack once we have limited contact view permissions
LEFT JOIN HasRelatedContacts hrc ON profiles.id = hrc."profileId"
LEFT JOIN LATERAL (SELECT COUNT(*) > 0 as "hasContacts", "profileId", "accountSid" FROM "Contacts" c WHERE profiles.id = c."profileId" AND profiles."accountSid" = c."accountSid" GROUP BY "profileId", "accountSid") hrc ON true
`;

export const getProfileByIdSql = getProfilesSqlBase(`
Expand Down