Skip to content

Conversation

@kkartunov
Copy link
Contributor

No description provided.

@kkartunov kkartunov requested a review from jmgasper November 11, 2025 07:28
CREATE SCHEMA IF NOT EXISTS reviews;

CREATE EXTENSION IF NOT EXISTS fuzzystrmatch WITH SCHEMA skills;
CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA pg_catalog;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ design]
The pg_trgm extension is being created in the pg_catalog schema. Typically, extensions are created in the public schema or a specific schema relevant to the application. Ensure that this is intentional and that the application logic accounts for this schema placement.

CREATE EXTENSION IF NOT EXISTS fuzzystrmatch WITH SCHEMA skills;
CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA pg_catalog;
CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA reviews;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA skills;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ design]
The uuid-ossp extension is being created in the skills schema. This is unusual as extensions are often placed in the public schema. Verify that this schema choice is deliberate and that it aligns with the application's schema management strategy.

JOIN pg_namespace ns ON ns.oid = idx.relnamespace
WHERE idx.relname = 'challenge_phase_challenge_open_end_idx'
AND ns.nspname = challenge_phase_schema
AND pg_get_indexdef(idx.oid) LIKE '%("challengeId", "isOpen", "scheduledEndDate", "actualEndDate", name)%'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
The pg_get_indexdef function is used with a LIKE clause to check index definitions. This approach can be fragile if the index definition changes in ways not accounted for by the LIKE pattern. Consider using a more robust method to verify index structure, if possible.

@@ -0,0 +1,30 @@
-- View to use in performance updates (PM-2206)
DROP VIEW IF EXISTS "challenges"."MemberChallengeAccess";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
Dropping the view without checking if it exists first could lead to errors if the view is not present. Consider using DROP VIEW IF EXISTS to avoid potential errors.

) THEN
EXECUTE format(
'CREATE VIEW %I.%I AS
SELECT DISTINCT r."challengeId", r."memberId"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ performance]
Using SELECT DISTINCT can be resource-intensive. Ensure that this is necessary for the use case, as it may impact performance.

'CREATE VIEW %I.%I AS
SELECT DISTINCT r."challengeId", r."memberId"
FROM resources."Resource" r
WHERE r."challengeId" IS NOT NULL

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ performance]
The condition r."challengeId" IS NOT NULL AND r."memberId" IS NOT NULL is used to filter out null values. Ensure that these columns are indexed if they are frequently queried, to improve performance.

terms ChallengeTerm[]
skills ChallengeSkill[]
auditLogs AuditLog[]
memberAccesses MemberChallengeAccess[]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
The addition of memberAccesses in the Challenge model introduces a new relation to MemberChallengeAccess. Ensure that the MemberChallengeAccess model is correctly populated and maintained, as any orphaned records could lead to inconsistencies. Consider adding cascading delete or update rules if appropriate.

challenge Challenge @relation(fields: [challengeId], references: [id])
@@id([challengeId, memberId])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
The composite primary key @@id([challengeId, memberId]) in MemberChallengeAccess ensures uniqueness of member/challenge pairs. Verify that this constraint aligns with the intended data model and that no existing data violates this constraint.

timelineTemplateId
);
const { phaseDefinitionMap } = await this.getPhaseDefinitionsAndMap();
const challengePhaseIds = new Set(_.map(challengePhases, "phaseId"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ performance]
Consider using _.keyBy instead of _.map followed by new Set to directly create a set of phase IDs. This could improve performance by reducing the number of iterations over challengePhases.

phaseId: phase.predecessor,
});
if (_.isNil(predecessorPhase)) {
continue;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The continue statement here skips processing phases without a valid predecessor. Ensure that this behavior is intentional and that skipping these phases won't lead to incorrect scheduling or logic errors.

@kkartunov kkartunov merged commit 016a1b3 into develop Nov 11, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants