Skip to content

fix(Filters): In search API #16

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

Merged
merged 2 commits into from
Aug 12, 2025
Merged

fix(Filters): In search API #16

merged 2 commits into from
Aug 12, 2025

Conversation

hentrymartin
Copy link
Collaborator

What's in this PR?

  • Added filters for status, scorecardType

@@ -31,6 +31,7 @@ import {
import { ChallengeTrack } from 'src/shared/enums/challengeTrack.enum';
import { ScoreCardService } from './scorecard.service';
import { PaginationHeaderInterceptor } from 'src/interceptors/PaginationHeaderInterceptor';
import { $Enums } from '@prisma/client';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming $Enums to a more descriptive name that reflects its purpose or the specific enums being imported. This will improve code readability and maintainability.

@@ -181,6 +194,9 @@ export class ScorecardController {
async searchScorecards(
@Query('challengeTrack') challengeTrack?: ChallengeTrack | ChallengeTrack[],
@Query('challengeType') challengeType?: string | string[],
@Query('status') status?: $Enums.ScorecardStatus | $Enums.ScorecardStatus[],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider checking if $Enums.ScorecardStatus is correctly imported and defined, as it is being used here for the status query parameter.

@@ -181,6 +194,9 @@ export class ScorecardController {
async searchScorecards(
@Query('challengeTrack') challengeTrack?: ChallengeTrack | ChallengeTrack[],
@Query('challengeType') challengeType?: string | string[],
@Query('status') status?: $Enums.ScorecardStatus | $Enums.ScorecardStatus[],
@Query('scorecardType')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that $Enums.ScorecardType is properly imported and defined, as it is being used for the scorecardType query parameter.

const result = await this.scorecardService.getScoreCards({
challengeTrack: challengeTrackArray,
challengeType: challengeTypeArray,
name,
page,
perPage,
scorecardTypesArray,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property name scorecardTypesArray should be passed as scorecardType to match the expected parameter name in the getScoreCards method, unless the method signature has been updated to expect scorecardTypesArray.

const result = await this.scorecardService.getScoreCards({
challengeTrack: challengeTrackArray,
challengeType: challengeTypeArray,
name,
page,
perPage,
scorecardTypesArray,
statusArray,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property name statusArray should be passed as status to match the expected parameter name in the getScoreCards method, unless the method signature has been updated to expect statusArray.

...(name && { name: { contains: name, mode: 'insensitive' } }),
};
console.log(where, 'asdkjalsd');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the console.log statement used for debugging. Leaving debugging statements in production code can lead to unnecessary console output and potential performance issues.

@@ -1,4 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import { $Enums } from '@prisma/client';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider importing only the necessary enums from @prisma/client to avoid importing unused code. This can help reduce the bundle size and improve performance.

status: {
in: statusArray,
},
}),
...(name && { name: { contains: name, mode: 'insensitive' } }),
};
const data = await this.prisma.scorecard.findMany({

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the commented-out console.log statement. Leaving commented-out code can clutter the codebase and is generally not recommended unless it serves a specific purpose, such as documentation or a temporary workaround.

@hentrymartin hentrymartin merged commit 7bf1a5f into feat/scorecards Aug 12, 2025
2 checks passed
@hentrymartin hentrymartin deleted the filters-fix branch August 12, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants