-
Notifications
You must be signed in to change notification settings - Fork 9
Add support for pulling specific review summations, not all review su… #174
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -544,6 +544,13 @@ export class ReviewSummationService { | |
| const skip = (page - 1) * perPage; | ||
| let orderBy; | ||
|
|
||
| const parseBooleanString = (value?: string): boolean | undefined => { | ||
| if (typeof value !== 'string') { | ||
| return undefined; | ||
| } | ||
| return value.toLowerCase() === 'true'; | ||
| }; | ||
|
|
||
| if (sortDto && sortDto.orderBy && sortDto.sortBy) { | ||
| orderBy = { | ||
| [sortDto.sortBy]: sortDto.orderBy.toLowerCase(), | ||
|
|
@@ -700,6 +707,14 @@ export class ReviewSummationService { | |
|
|
||
| // Build the where clause for review summations based on available filter parameters | ||
| const reviewSummationWhereClause: any = {}; | ||
| const isPassingFilter = parseBooleanString(queryDto.isPassing); | ||
| const isFinalFilter = parseBooleanString(queryDto.isFinal); | ||
| const isProvisionalFilter = parseBooleanString(queryDto.isProvisional); | ||
| const isExampleFilter = parseBooleanString(queryDto.isExample); | ||
| const exampleOnly = parseBooleanString(queryDto.example) === true; | ||
| const provisionalOnly = parseBooleanString(queryDto.provisional) === true; | ||
| const systemOnly = parseBooleanString(queryDto.system) === true; | ||
|
|
||
| if (queryDto.submissionId) { | ||
| reviewSummationWhereClause.submissionId = queryDto.submissionId; | ||
| } | ||
|
|
@@ -711,21 +726,23 @@ export class ReviewSummationService { | |
| if (queryDto.scorecardId) { | ||
| reviewSummationWhereClause.scorecardId = queryDto.scorecardId; | ||
| } | ||
| if (queryDto.isPassing !== undefined) { | ||
| reviewSummationWhereClause.isPassing = | ||
| queryDto.isPassing.toLowerCase() === 'true'; | ||
| if (isPassingFilter !== undefined) { | ||
| reviewSummationWhereClause.isPassing = isPassingFilter; | ||
| } | ||
| if (queryDto.isFinal !== undefined) { | ||
| reviewSummationWhereClause.isFinal = | ||
| queryDto.isFinal.toLowerCase() === 'true'; | ||
| if (isFinalFilter !== undefined) { | ||
| reviewSummationWhereClause.isFinal = isFinalFilter; | ||
| } else if (systemOnly) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| reviewSummationWhereClause.isFinal = true; | ||
| } | ||
| if (queryDto.isProvisional !== undefined) { | ||
| reviewSummationWhereClause.isProvisional = | ||
| queryDto.isProvisional.toLowerCase() === 'true'; | ||
| if (isProvisionalFilter !== undefined) { | ||
| reviewSummationWhereClause.isProvisional = isProvisionalFilter; | ||
| } else if (provisionalOnly) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| reviewSummationWhereClause.isProvisional = true; | ||
| } | ||
| if (queryDto.isExample !== undefined) { | ||
| reviewSummationWhereClause.isExample = | ||
| queryDto.isExample.toLowerCase() === 'true'; | ||
| if (isExampleFilter !== undefined) { | ||
| reviewSummationWhereClause.isExample = isExampleFilter; | ||
| } else if (exampleOnly) { | ||
| reviewSummationWhereClause.isExample = true; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| } | ||
|
|
||
| const submissionWhereClause: Record<string, unknown> = {}; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,6 +70,33 @@ export class ReviewSummationQueryDto { | |
| @IsBooleanString() | ||
| isExample?: string; | ||
|
|
||
| @ApiProperty({ | ||
| description: | ||
| 'When true, only include review summations flagged as examples (isExample = true)', | ||
| required: false, | ||
| }) | ||
| @IsOptional() | ||
| @IsBooleanString() | ||
| example?: string; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
|
|
||
| @ApiProperty({ | ||
| description: | ||
| 'When true, only include provisional review summations (isProvisional = true)', | ||
| required: false, | ||
| }) | ||
| @IsOptional() | ||
| @IsBooleanString() | ||
| provisional?: string; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
|
|
||
| @ApiProperty({ | ||
| description: | ||
| 'When true, only include system (final) review summations (isFinal = true)', | ||
| required: false, | ||
| }) | ||
| @IsOptional() | ||
| @IsBooleanString() | ||
| system?: string; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
|
|
||
| @ApiProperty({ | ||
| description: 'The challenge id tied to the submission', | ||
| required: false, | ||
|
|
||
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.
[⚠️
correctness]The
parseBooleanStringfunction returnsundefinedfor non-string inputs, which might not be the expected behavior if the input isnullorundefined. Consider explicitly handling these cases to avoid potential issues in the calling code.