Conversation
Further performance update for my-reviews
| `, | ||
| ); | ||
| cteFragments.push( | ||
| Prisma.sql` |
There was a problem hiding this comment.
[performance]
The use of COUNT(*)::bigint and SUM(...)::bigint is consistent with the previous implementation, but ensure that the casting to bigint is necessary for the application logic. If the counts are expected to be within the range of integer, this casting might be unnecessary and could be optimized.
| ); | ||
| cteFragments.push( | ||
| Prisma.sql` | ||
| incomplete_reviews AS ( |
There was a problem hiding this comment.
[correctness]
The DISTINCT ON clause is used here to select unique resourceId entries. Ensure that this approach aligns with the intended logic, as DISTINCT ON can sometimes lead to unexpected results if the ordering is not carefully considered.
|
|
||
| const reviewTotalsJoin = adminUser | ||
| ? Prisma.sql` | ||
| LEFT JOIN LATERAL ( |
There was a problem hiding this comment.
[correctness]
The conditional logic for adminUser results in different SQL joins. Verify that the logic correctly handles all cases, especially when transitioning between admin and non-admin users, to ensure that the correct data is retrieved.
|
|
||
| const incompleteReviewsJoin = adminUser | ||
| ? Prisma.sql` | ||
| LEFT JOIN LATERAL ( |
There was a problem hiding this comment.
[maintainability]
The logic for determining hasIncompleteReviews and incompletePhaseName is duplicated for admin and non-admin users. Consider refactoring to reduce redundancy and improve maintainability.
No description provided.