feat(PM-4288): Open to work column and filter implementation#60
feat(PM-4288): Open to work column and filter implementation#60hentrymartin merged 5 commits intodevelopfrom
Conversation
| ORDER BY mt."updatedAt" DESC | ||
| LIMIT 1 | ||
| ) ot ON TRUE | ||
| LEFT JOIN LATERAL ( |
There was a problem hiding this comment.
[performance]
Using LEFT JOIN LATERAL with ON TRUE can lead to performance issues if the subquery is complex or returns a large dataset. Consider whether this is necessary or if a different join condition could be more efficient.
| ORDER BY m.handle | ||
| LIMIT $2::int | ||
| OFFSET $3::int; | ||
| LIMIT $3::int |
There was a problem hiding this comment.
[❗❗ security]
Ensure that the LIMIT and OFFSET values are validated before being passed to the query to prevent potential SQL injection vulnerabilities.
| perPage = 50, | ||
| openToWork?: boolean, | ||
| ) { | ||
| const safePage = Number.isFinite(page) ? Math.max(Math.floor(page), 1) : 1; |
There was a problem hiding this comment.
[correctness]
The safePage calculation uses Math.floor(page), which could lead to unexpected results if page is a non-integer. Consider using Math.ceil(page) to ensure that any fractional page numbers round up to the next whole page, or validate that page is an integer before this calculation.
| ) { | ||
| const safePage = Number.isFinite(page) ? Math.max(Math.floor(page), 1) : 1; | ||
| const safePerPage = Number.isFinite(perPage) | ||
| ? Math.min(Math.max(Math.floor(perPage), 1), 200) |
There was a problem hiding this comment.
[correctness]
The safePerPage calculation uses Math.floor(perPage), which could lead to unexpected results if perPage is a non-integer. Consider using Math.ceil(perPage) to ensure that any fractional perPage numbers round up to the next whole number, or validate that perPage is an integer before this calculation.
| typeof openToWork === "boolean" ? openToWork : null, | ||
| ], | ||
| ); | ||
| const total = Number(countRows?.[0]?.total ?? 0); |
There was a problem hiding this comment.
[correctness]
The total variable is calculated using Number(countRows?.[0]?.total ?? 0). If total is expected to be a non-negative integer, consider adding validation to ensure that countRows?.[0]?.total is a valid number before conversion.
| @@ -689,6 +698,7 @@ export class TopcoderReportsService { | |||
| row.skillCount !== null && row.skillCount !== undefined | |||
There was a problem hiding this comment.
[correctness]
The conversion of row.skillCount to a number assumes that row.skillCount is a valid numeric string or number. Consider adding validation to handle cases where row.skillCount might not be a valid number.
What's in this PR?
Ticket link - https://topcoder.atlassian.net/browse/PM-4288