Skip to content

Fix completion date filter issue for challenge reports#51

Merged
jmgasper merged 2 commits intomasterfrom
develop
Feb 25, 2026
Merged

Fix completion date filter issue for challenge reports#51
jmgasper merged 2 commits intomasterfrom
develop

Conversation

@jmgasper
Copy link
Collaborator

No description provided.

@jmgasper jmgasper merged commit 7277853 into master Feb 25, 2026
5 of 6 checks passed
c."projectId" as "projectId"
FROM
challenges."Challenge" c
LEFT JOIN LATERAL (

Choose a reason for hiding this comment

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

[⚠️ performance]
The use of LEFT JOIN LATERAL is a good choice for fetching the latest phase's actualEndDate. However, ensure that the database engine being used supports this feature efficiently, as it might have performance implications depending on the size of the ChallengePhase table.

LIMIT 1
) >= $4::timestamptz
)
latest_phase."actualEndDate" IS NOT NULL

Choose a reason for hiding this comment

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

[⚠️ correctness]
The condition latest_phase."actualEndDate" IS NOT NULL is crucial for ensuring that the date filters are applied only when an actual end date exists. This is a good safeguard for correctness, but be aware that it might exclude challenges that are completed but have no recorded end date, depending on the data integrity.

ROUND(sub."finalScore", 2) as "registrantFinalScore"
FROM
challenges."Challenge" c
LEFT JOIN LATERAL (

Choose a reason for hiding this comment

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

[⚠️ maintainability]
The use of LEFT JOIN LATERAL is appropriate here to simplify the query logic by removing the repeated subquery. However, ensure that the database engine being used supports LATERAL joins, as not all databases do. This could impact portability if the query is intended to be used across different database systems.

-- filter by challengeCompletedDate
AND (c.status!='COMPLETED' OR (
-- filter by completion date bounds on the latest challenge phase end date
AND (

Choose a reason for hiding this comment

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

[⚠️ correctness]
The condition latest_phase."actualEndDate" IS NOT NULL is crucial for ensuring that the subsequent comparisons with $4 and $5 are valid. However, consider whether there should be additional handling or logging for cases where latest_phase."actualEndDate" is NULL, as this could indicate incomplete data for a 'COMPLETED' challenge.

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.

1 participant