Skip to content
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
26 changes: 24 additions & 2 deletions sql/reports/topgear/hourly.sql
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,24 @@ submitter_roles AS (
SELECT id
FROM resources."ResourceRole"
WHERE COALESCE("nameLower", LOWER(name)) = 'submitter'
),
registration_end AS (
SELECT
cp."challengeId" AS challenge_id,
MAX(COALESCE(cp."actualEndDate", cp."scheduledEndDate")) AS registration_end_date
Copy link

Choose a reason for hiding this comment

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

[⚠️ correctness]
Using MAX(COALESCE(cp."actualEndDate", cp."scheduledEndDate")) to determine the registration_end_date assumes that the maximum of these dates is always the correct end date. Consider whether this logic accurately reflects the business rules, as it may not account for scenarios where the scheduled end date should take precedence over the actual end date.

FROM challenges."ChallengePhase" cp
JOIN challenges."Phase" p ON p.id = cp."phaseId"
WHERE p.name = 'Registration'
GROUP BY cp."challengeId"
),
submission_end AS (
SELECT
cp."challengeId" AS challenge_id,
MAX(COALESCE(cp."actualEndDate", cp."scheduledEndDate")) AS submission_end_date
Copy link

Choose a reason for hiding this comment

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

[⚠️ correctness]
Using MAX(COALESCE(cp."actualEndDate", cp."scheduledEndDate")) to determine the submission_end_date assumes that the maximum of these dates is always the correct end date. Ensure this logic aligns with the intended business rules, as it may not handle cases where the scheduled end date should override the actual end date.

FROM challenges."ChallengePhase" cp
JOIN challenges."Phase" p ON p.id = cp."phaseId"
WHERE p.name IN ('Topcoder Submission', 'Submission')
GROUP BY cp."challengeId"
)
SELECT
bc."updatedAt" AS modify_date,
Expand All @@ -99,8 +117,8 @@ SELECT
bc.name AS challenge_name,
bc.status AS challenge_status,
ct.name AS challenge_type,
bc."registrationEndDate" AS registration_end_date,
bc."submissionEndDate" AS submission_end_date,
re.registration_end_date AS registration_end_date,
se.submission_end_date AS submission_end_date,
pd.latest_actual_end_date AS completed_date,
mt.onsite_efforts AS onsite_efforts,
mt.offsite_efforts AS offsite_efforts,
Expand Down Expand Up @@ -194,6 +212,10 @@ LEFT JOIN tag_list tl
ON tl.challenge_id = bc.id
LEFT JOIN group_list gl
ON gl.challenge_id = bc.id
LEFT JOIN registration_end re
ON re.challenge_id = bc.id
LEFT JOIN submission_end se
ON se.challenge_id = bc.id
LEFT JOIN LATERAL (
SELECT
MAX(cp."actualEndDate") AS latest_actual_end_date
Expand Down
Loading