-
Notifications
You must be signed in to change notification settings - Fork 0
Performance enhancements for prod data #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| cb."challengeId" AS challenge_id, | ||
| MAX(cb."billingAccountId") FILTER (WHERE cb."billingAccountId" IS NOT NULL) AS billing_account_id | ||
| FROM challenges."ChallengeBilling" cb | ||
| WHERE cb."billingAccountId" = '80000062' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[maintainability]
The filter condition cb."billingAccountId" = '80000062' is hardcoded. Consider parameterizing this value to improve maintainability and flexibility of the query.
| FROM challenges."Challenge" c | ||
| JOIN bill b | ||
| ON b.challenge_id = c.id | ||
| WHERE c."createdAt" >= now() - interval '4 months' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[maintainability]
The condition c."createdAt" >= now() - interval '4 months' is repeated in the main query and the base_challenges CTE. Ensure this logic is consistent across all usages or consider centralizing this logic to avoid potential discrepancies.
| bc."registrationStartDate" AS registration_start_date, | ||
| CASE | ||
| WHEN bc.status = 'COMPLETED' | ||
| AND bc."createdAt" > '2025-01-01T00:00:00Z' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[maintainability]
The condition bc."createdAt" > '2025-01-01T00:00:00Z' is repeated multiple times. Consider defining this as a constant or parameter to enhance maintainability and reduce the risk of errors if the date needs to be updated.
| WHERE p.winnings_id = w.winning_id | ||
| ) ps ON TRUE | ||
| WHERE r."challengeId" = bc.id | ||
| AND bc."createdAt" > '2025-01-01T00:00:00Z' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[maintainability]
The condition bc.status IN ('ACTIVE', 'COMPLETED') is used multiple times. Consider defining this as a constant or parameter to improve maintainability and ensure consistency across the query.
| AND bc.status = 'COMPLETED' | ||
| AND bc."createdAt" > '2025-01-01T00:00:00Z' | ||
| ) cp ON TRUE | ||
| WHERE bc.billing_account_id = '80000062' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[maintainability]
The condition bc.billing_account_id = '80000062' is hardcoded. Consider parameterizing this value to improve maintainability and flexibility of the query.
No description provided.