Skip to content

Commit d60b831

Browse files
authored
Merge pull request #16 from topcoder-platform/pm-1259_2
fix(PM-1259): submission link to date query and registrants details sql
2 parents 99377f6 + 80eda32 commit d60b831

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

sql/reports/topgear/topgear-registrants-details.sql

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ proj AS (
5858
p."billingAccountId"::bigint AS project_billing_account_id
5959
FROM projects.projects p
6060
),
61+
proj_phase_end AS (
62+
SELECT
63+
pp."projectId"::bigint AS project_id, -- cast to text to match base.project_id
64+
MAX(pp."endDate") AS project_scheduled_end_date
65+
FROM projects."project_phases" pp
66+
WHERE pp.status ILIKE 'planned'
67+
GROUP BY pp."projectId"
68+
),
6169
registrants AS (
6270
SELECT
6371
r."challengeId" AS challenge_id,
@@ -82,7 +90,7 @@ SELECT
8290
proj.group_customer_name AS "Customer name",
8391
reg.registrant_email AS "Registrant email",
8492
CASE WHEN base.challenge_status = 'ACTIVE'
85-
THEN base.planned_end_at END AS "Project scheduled end date",
93+
THEN ppe.project_scheduled_end_date END AS "Project scheduled end date",
8694
sub.best_final_score AS "Submission score"
8795
FROM base
8896
JOIN registrants reg
@@ -100,11 +108,19 @@ LEFT JOIN billing b
100108
ON b.challenge_id = base.challenge_id
101109
LEFT JOIN proj
102110
ON proj.project_id = base.project_id
111+
LEFT JOIN proj_phase_end ppe
112+
ON ppe.project_id = base.project_id
103113
WHERE
104114
COALESCE(b.billing_account_id, proj.project_billing_account_id) = 80000062
105-
AND COALESCE(
106-
CASE WHEN base.challenge_status = 'COMPLETED' THEN lp.last_phase_end END,
107-
base.planned_end_at,
108-
base.challenge_created_at
109-
) BETWEEN $1::timestamptz AND $2::timestamptz
115+
AND (
116+
(base.challenge_status = 'COMPLETED'
117+
AND lp.last_phase_end BETWEEN $1::timestamptz AND $2::timestamptz
118+
)
119+
OR
120+
(base.challenge_status = 'ACTIVE' AND (
121+
base.challenge_created_at BETWEEN $1::timestamptz AND $2::timestamptz
122+
OR base.challenge_updated_at BETWEEN $1::timestamptz AND $2::timestamptz
123+
OR base.planned_end_at BETWEEN $1::timestamptz AND $2::timestamptz
124+
))
125+
)
110126
ORDER BY base.challenge_id DESC, reg.registrant_handle;

src/reports/challenges/dtos/submission-links.dto.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export class SubmissionLinksQueryDto {
2525
})
2626
@IsOptional()
2727
@IsDateString()
28+
@Transform(({ value }) => value || new Date().toISOString())
2829
completionDateTo?: Date;
2930

3031
@ApiProperty({

0 commit comments

Comments
 (0)