Conversation
| SELECT DISTINCT | ||
| ma."userId" | ||
| FROM members."memberAddress" ma | ||
| WHERE ma.city IS NOT NULL |
There was a problem hiding this comment.
[correctness]
Consider adding a check for ma."homeCountryCode" being non-null in the member_location CTE to ensure consistency with the profile completion criteria outlined in the comments.
| ON mtp."memberTraitId" = mt.id | ||
| WHERE mt."traitId" = 'personalization' | ||
| AND mtp.value IS NOT NULL | ||
| AND mtp.value::jsonb ? 'openToWork' |
There was a problem hiding this comment.
[correctness]
The condition mtp.value::jsonb ? 'openToWork' checks for the presence of the key but does not verify its value. Ensure that the presence of this key alone is sufficient for the logic or consider checking its value if necessary.
| AND mtp.value IS NOT NULL | ||
| AND mtp.value::jsonb ? 'availability' | ||
| AND mtp.value::jsonb ->> 'availability' IS NOT NULL | ||
| AND mtp.value::jsonb ? 'preferredRoles' |
There was a problem hiding this comment.
[❗❗ correctness]
The removal of the check jsonb_typeof(mtp.value::jsonb -> 'availability') = 'boolean' could lead to incorrect data being considered valid. Ensure that the availability field is always a boolean to maintain data integrity.
| ON mtp."memberTraitId" = mt.id | ||
| WHERE mtp.key = 'openToWork' | ||
| AND mtp.value IS NOT NULL | ||
| AND ( |
There was a problem hiding this comment.
[❗❗ correctness]
The logic for checking availability and preferredRoles has changed. Previously, both availability and preferredRoles were required. Now, availability is optional if preferredRoles is present and non-empty. Ensure this change aligns with the intended business logic, as it alters the criteria for a completed profile.
| AND me."userId" IS NOT NULL | ||
| AND ml."userId" IS NOT NULL | ||
| AND ($1::text IS NULL OR COALESCE(m."homeCountryCode", m."competitionCountryCode") = $1) | ||
| HAVING COUNT(*) >= 3 -- Filter early to reduce dataset |
There was a problem hiding this comment.
[correctness]
The HAVING COUNT(*) >= 3 clause is used to filter users with at least 3 skills early in the member_skills CTE. This is a good optimization to reduce the dataset size early on. However, ensure that this logic aligns with the business requirements, as it might exclude users who have fewer than 3 skills but meet other profile completion criteria.
| COALESCE(m."homeCountryCode", m."competitionCountryCode") AS "countryCode", | ||
| m.country AS "countryName" | ||
| FROM members.member m | ||
| INNER JOIN member_skills ms ON ms.user_id = m."userId" |
There was a problem hiding this comment.
[correctness]
The INNER JOIN on member_skills ensures that only members with at least 3 skills are included. This is a change from the previous LEFT JOIN which allowed members with fewer skills to be included. Verify that this change aligns with the intended logic for profile completion.
| AND m."photoURL" IS NOT NULL | ||
| AND m."photoURL" <> '' | ||
| AND m."homeCountryCode" IS NOT NULL | ||
| AND ($1::text IS NULL OR COALESCE(m."homeCountryCode", m."competitionCountryCode") = $1) |
There was a problem hiding this comment.
[correctness]
The condition m."homeCountryCode" IS NOT NULL is used to filter members. Ensure that this condition is necessary and does not conflict with the logic that uses COALESCE(m."homeCountryCode", m."competitionCountryCode") for determining the countryCode. If homeCountryCode is always required, consider removing the COALESCE logic.
https://topcoder.atlassian.net/browse/PM-4168 - Open To Work - Profile Completion