Skip to content

Add Interview Filters - #52

Merged
Harish-Naruto merged 4 commits into
mainfrom
interview-pagination
Nov 17, 2025
Merged

Add Interview Filters#52
Harish-Naruto merged 4 commits into
mainfrom
interview-pagination

Conversation

@Sherin-2711

@Sherin-2711Sherin-2711 commented Nov 17, 2025

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Added ability to filter interview results by verdict with "All" as the default to show all entries; allowed values: All, Selected, Rejected, Pending.
  • Improvements

    • Verdict filter applied to list and count results; verdict is now returned in interview responses for clearer feedback.
  • Tests

    • Updated tests to expect the verdict field in responses.

@coderabbitai

coderabbitaiBot commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a verdict query parameter (default "All") to the interviews endpoint, validates allowed values, threads it from controller to service, applies an optional where-filter in the service query, and includes verdict in the JSON response. Tests updated to expect the new field.

Changes

Cohort / File(s)Summary
Controller update
src/controllers/interview.controller.ts
Added verdict query parameter (default "All"), validated allowed values, forwarded verdict to service, included verdict in JSON response.
Service update
src/services/interview.service.ts
Updated getInterviews(page, limit, verdict) signature; applies conditional where filter when verdict !== "All" and uses it for findMany and count.
Test expectation
tests/Interview.test.ts
Updated test to expect verdict: "All" in the getInterviews JSON response payload (plus minor whitespace change).

Sequence Diagram(s)

sequenceDiagram
participant Client
participant Controller as interview.controller
participant Service as interview.service
participant DB as Prisma/Database
Client->>Controller: GET /interviews?page=1&limit=10&verdict=Selected
Controller->>Controller: Parse & validate `verdict` (default "All")
Controller->>Service: getInterviews(page, limit, verdict)
alt verdict != "All"
Service->>Service: Build where = { verdict: verdict }
else verdict == "All"
Service->>Service: where = {}
end
Service->>DB: findMany(where, pagination, include)
DB-->>Service: Interview records
Service-->>Controller: { interviews, verdict, meta }
Controller-->>Client: JSON response
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Areas to check:
    • Consistency of allowed-verdict values between controller and service.
    • Default behavior when verdict is omitted ("All").
    • Tests updated to match response shape and any pagination/meta fields.

Possibly related PRs

  • Interview pagination #50 — Modifies the same getInterviews API surface (controller/service signature and response), likely related.

Suggested reviewers

  • i-am-that-guy
  • Harish-Naruto

Poem

🐇 A verdict hops into the queue,
Passed from controller straight to you,
"All" by default, or pick the set,
Service filters, tests do fret,
Tiny change — the burrow's new view.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'Add Interview Filters' accurately reflects the main change: introducing a verdict filter parameter to the getInterviews functionality across controller, service, and tests.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch interview-pagination

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2160f06 and 574cd06.

📒 Files selected for processing (1)
  • src/services/interview.service.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/services/interview.service.ts (3)
src/controllers/interview.controller.ts (1)
  • getInterviews (5-32)
src/services/member.service.ts (1)
  • getInterviews (142-146)
src/db/client.ts (1)
  • prisma (5-5)
🪛 ESLint
src/services/interview.service.ts

[error] 6-6: Unexpected any. Specify a different type.

(@typescript-eslint/no-explicit-any)


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/services/interview.service.ts (1)

30-30: Critical: Total count ignores verdict filter.

The count query doesn't apply the where filter, so when filtering by verdict, the total count and totalPages will be incorrect. For example, filtering by "Selected" will return the count of all interviews, not just selected ones.

Apply this diff to fix the count:

- prisma.interviewExperience.count(),+ prisma.interviewExperience.count({ where }),
🧹 Nitpick comments (1)
src/services/interview.service.ts (1)

3-3: LGTM with minor style suggestion.

The signature correctly adds the verdict parameter with an appropriate default value.

Consider fixing the spacing for consistency with TypeScript conventions:

-export const getInterviews = async (page: number = 1, limit: number = 10, verdict : string = "All") => {+export const getInterviews = async (page: number = 1, limit: number = 10, verdict: string = "All") => {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a91c6b and 41f6693.

📒 Files selected for processing (3)
  • src/controllers/interview.controller.ts (2 hunks)
  • src/services/interview.service.ts (1 hunks)
  • tests/Interview.test.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/services/interview.service.ts (2)
src/controllers/interview.controller.ts (1)
  • getInterviews (5-28)
src/services/member.service.ts (1)
  • getInterviews (142-146)
🪛 ESLint
src/services/interview.service.ts

[error] 6-6: Unexpected any. Specify a different type.

(@typescript-eslint/no-explicit-any)

🔇 Additional comments (5)
tests/Interview.test.ts (2)

52-52: Verify service call includes verdict parameter.

The test expectation correctly reflects the new response structure, but the mock verification doesn't confirm that interviewService.getInterviews is called with the verdict parameter.

Consider adding an assertion to verify the service is called with all three parameters:

 await getInterviews(req, res);
+expect(interviewService.getInterviews).toHaveBeenCalledWith(1, 10, "All");
expect(res.status).toHaveBeenCalledWith(200);

59-59: LGTM!

Good formatting improvement for test separation.

src/controllers/interview.controller.ts (2)

17-17: LGTM!

Correctly passes the verdict parameter to the service layer.


24-24: LGTM!

Including verdict in the response payload provides useful context to API consumers about the applied filter.

src/services/interview.service.ts (1)

13-13: LGTM!

Correctly applies the dynamic where filter to the query.

Comment threadsrc/controllers/interview.controller.ts
Comment on lines +6 to +9
const where : any = {}
if(verdict !== "All"){
where.verdict = verdict
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Replace any type with proper Prisma typing.

Using any defeats TypeScript's type safety and is flagged by static analysis. The where clause should use Prisma's generated types.

Apply this diff to use proper typing:

-const where : any = {}+const where: Prisma.InterviewExperienceWhereInput = {}
if(verdict !== "All"){
where.verdict = verdict
}

You'll need to import the Prisma namespace at the top of the file:

-import { prisma } from "../db/client"+import { prisma, Prisma } from "../db/client"
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
constwhere : any={}
if(verdict!=="All"){
where.verdict=verdict
}
constwhere: Prisma.InterviewExperienceWhereInput={}
if(verdict!=="All"){
where.verdict=verdict
}
🧰 Tools
🪛 ESLint

[error] 6-6: Unexpected any. Specify a different type.

(@typescript-eslint/no-explicit-any)

🤖 Prompt for AI Agents
In src/services/interview.service.ts around lines 6 to 9, the variable "where"
is currently typed as "any" which bypasses TypeScript/Prisma typings; change it
to the appropriate Prisma generated type (e.g., Prisma.InterviewWhereInput) and
update usage accordingly so "where.verdict = verdict" remains valid. Add an
import for the Prisma namespace at the top of the file (import { Prisma } from
'@prisma/client') and declare "const where: Prisma.InterviewWhereInput = {}" (or
the exact model WhereInput name if different), preserving the conditional
assignment when verdict !== "All". Ensure no other "any" remains for the where
clause.

@Harish-Naruto
Harish-Naruto merged commit 715c08d into mainNov 17, 2025
2 checks passed
@Harish-Naruto
Harish-Naruto deleted the interview-pagination branch November 17, 2025 11:33
@coderabbitaicoderabbitaiBot mentioned this pull request Nov 19, 2025
Sign up for freeto 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

@Sherin-2711@Harish-Naruto