Skip to content

feat: adds param to get filtered claims by checked field#117

Merged
semmet95 merged 6 commits into
mainfrom
feat/get-unchecked-claims
May 26, 2026
Merged

feat: adds param to get filtered claims by checked field#117
semmet95 merged 6 commits into
mainfrom
feat/get-unchecked-claims

Conversation

@semmet95
Copy link
Copy Markdown
Contributor

@semmet95 semmet95 commented May 25, 2026

Summary by CodeRabbit

  • New Features

    • Filter claims by checked status via the claims listing endpoint using the checked query parameter (true/false).
  • Documentation

    • API spec updated to document the checked query parameter and a 400 Invalid request parameters response.
  • Tests

    • Added acceptance and unit tests covering checked/unchecked filtering and input validation.

Review Change Stack

semmet95 added 5 commits May 25, 2026 18:12
Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: Amit Singh <singhamitch@outlook.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3e4ac4a0-53d0-4e60-8dc9-6a08c96b2682

📥 Commits

Reviewing files that changed from the base of the PR and between 0610aa3 and 332b97c.

📒 Files selected for processing (2)
  • api/source-score.yaml
  • pkg/domain/claim/claim_service_test.go

📝 Walkthrough

Walkthrough

This PR adds optional filtering support to the claims listing API via a new checked query parameter. The change propagates through the database client (supporting filters), domain (new ClaimFilter, repo and service signatures), HTTP handler and OpenAPI spec, and updates unit and acceptance tests.

Changes

Claims Checked Filter Implementation

Layer / File(s) Summary
Database and Repository Filtering Foundation
pkg/db/pgsql/client.go, pkg/domain/proof/proof_repository.go, pkg/domain/source/source_repository.go
FindAll method now accepts an optional filters parameter applied via Where clause. Repository methods for claims, proofs, and sources are updated to explicitly pass model parameters to FindAll.
Claim Domain Filtering Contracts and Implementation
pkg/domain/claim/claim_repository.go, pkg/domain/claim/claim_service.go
ClaimFilter type with optional Checked field is introduced. ClaimRepository.GetClaims and ClaimService.GetClaims interfaces and implementations are updated to accept and forward the filter through the data access chain.
Handler and OpenAPI Specification
api/source-score.yaml, pkg/handlers/claim.go
OpenAPI spec documents the optional checked boolean query parameter. Handler parses the parameter via strconv.ParseBool, validates it, constructs a ClaimFilter, and passes it to the service.
Fake Implementations and Unit Tests
pkg/domain/claim/claimfakes/fake_claim_repository.go, pkg/domain/claim/claimfakes/fake_claim_service.go, pkg/domain/claim/claim_repository_test.go, pkg/domain/claim/claim_service_test.go
Fake test doubles are updated to match the two-argument GetClaims signature. Repository and service unit tests pass explicit filter arguments and include new test cases verifying filtering behavior when Checked is true.
Acceptance Tests and Configuration
acceptance/claim_test.go, .gitignore
End-to-end tests verify the checked parameter correctly filters claims by status. Repository ignore rules are updated for build cache artifacts.

Sequence Diagram

sequenceDiagram
  participant Handler
  participant Service as ClaimService
  participant Repo as ClaimRepository
  participant DB as pgsql.Client
  Handler->>Service: GetClaims(ctx, ClaimFilter{Checked: bool})
  Service->>Repo: GetClaims(ctx, ClaimFilter)
  Repo->>DB: FindAll(ctx, &api.Claim{}, filterFields{Checked})
  DB->>Repo: []api.Claim
  Repo->>Service: []api.Claim
  Service->>Handler: []api.Claim
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A tiny filter hops through code so spry,

checked true or false beneath the sky,
Handler parses, service sends it down,
DB returns the claims without a frown,
Tests cheer softly: all paths comply.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a parameter to filter claims by their checked status, which is reflected throughout all modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/get-unchecked-claims

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.

@semmet95 semmet95 marked this pull request as ready for review May 25, 2026 17:41
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@api/source-score.yaml`:
- Around line 171-177: Add a 400 Bad Request response to the OpenAPI operation
for GET /api/v1/claims to reflect that an unparsable checked query parameter can
cause a 400; update the responses block in api/source-score.yaml for the GET
/api/v1/claims operation to include a 400 response schema/description (matching
the project's error response shape) so generated clients and docs match the
runtime behavior when the checked query value is invalid.

In `@pkg/domain/claim/claim_service_test.go`:
- Around line 79-81: The test sets a global default return on the shared fake
using fakeClaimRepo.GetClaimsReturns which can leak state into other specs;
replace that with a per-call return by capturing the current call index
(callsBefore := fakeClaimRepo.GetClaimsCallCount()) and then call
fakeClaimRepo.GetClaimsReturnsOnCall(callsBefore, expected, nil) so only this
specific call returns the expected value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f4308a3b-7666-4b7a-92af-1e0e7f9eadeb

📥 Commits

Reviewing files that changed from the base of the PR and between 35b6260 and 0610aa3.

📒 Files selected for processing (13)
  • .gitignore
  • acceptance/claim_test.go
  • api/source-score.yaml
  • pkg/db/pgsql/client.go
  • pkg/domain/claim/claim_repository.go
  • pkg/domain/claim/claim_repository_test.go
  • pkg/domain/claim/claim_service.go
  • pkg/domain/claim/claim_service_test.go
  • pkg/domain/claim/claimfakes/fake_claim_repository.go
  • pkg/domain/claim/claimfakes/fake_claim_service.go
  • pkg/domain/proof/proof_repository.go
  • pkg/domain/source/source_repository.go
  • pkg/handlers/claim.go

Comment thread api/source-score.yaml
Comment thread pkg/domain/claim/claim_service_test.go
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 13 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="api/source-score.yaml">

<violation number="1" location="api/source-score.yaml:176">
P2: The `checked` query parameter can trigger a `400 Bad Request` response (see handler at `pkg/handlers/claim.go` lines 36-40), but the OpenAPI spec only declares a `200` response for this operation. Add a `400` response to keep the API contract accurate for clients and generated SDKs.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread api/source-score.yaml
Signed-off-by: Amit Singh <singhamitch@outlook.com>
@semmet95 semmet95 merged commit 7fb3435 into main May 26, 2026
6 checks passed
@semmet95 semmet95 deleted the feat/get-unchecked-claims branch May 26, 2026 06:19
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.

1 participant