Skip to content

Commit 29ed6a9

Browse files
authored
Merge pull request #24 from topcoder-platform/develop
Fix for completed dates in Topgear houlrly report
2 parents 8ed3873 + da627b2 commit 29ed6a9

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

sql/reports/topgear/hourly.sql

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ SELECT
103103
ct.name AS challenge_type,
104104
bc."registrationEndDate" AS registration_end_date,
105105
bc."submissionEndDate" AS submission_end_date,
106-
bc."endDate" AS completed_date,
106+
pd.latest_actual_end_date AS completed_date,
107107
mt.onsite_efforts AS onsite_efforts,
108108
mt.offsite_efforts AS offsite_efforts,
109109
COALESCE(rv.num_reviews, 0) AS num_reviews,
@@ -133,13 +133,13 @@ SELECT
133133
bc."createdBy" AS creator,
134134
bc."createdAt" AS creation_date,
135135
CASE
136-
WHEN bc.status = 'COMPLETED' AND bc."endDate" IS NOT NULL
137-
THEN to_char(bc."endDate", 'Mon-YY')
136+
WHEN bc.status = 'COMPLETED' AND pd.latest_actual_end_date IS NOT NULL
137+
THEN to_char(pd.latest_actual_end_date, 'Mon-YY')
138138
ELSE NULL
139139
END AS completed_month,
140140
CASE
141-
WHEN bc.status = 'COMPLETED' AND bc."endDate" IS NOT NULL
142-
THEN to_char(bc."endDate", 'DD-Mon-YYYY HH24:MI:SS')
141+
WHEN bc.status = 'COMPLETED' AND pd.latest_actual_end_date IS NOT NULL
142+
THEN to_char(pd.latest_actual_end_date, 'DD-Mon-YYYY HH24:MI:SS')
143143
ELSE NULL
144144
END AS completed_date_formatted,
145145
bc."registrationStartDate" AS registration_start_date,
@@ -196,6 +196,12 @@ LEFT JOIN tag_list tl
196196
ON tl.challenge_id = bc.id
197197
LEFT JOIN group_list gl
198198
ON gl.challenge_id = bc.id
199+
LEFT JOIN LATERAL (
200+
SELECT
201+
MAX(cp."actualEndDate") AS latest_actual_end_date
202+
FROM challenges."ChallengePhase" cp
203+
WHERE cp."challengeId" = bc.id
204+
) pd ON TRUE
199205
LEFT JOIN LATERAL (
200206
SELECT
201207
COUNT(*)::int AS num_submissions,

0 commit comments

Comments
 (0)