Skip to content

4 add bulk delete contacts - #19

Merged
yamcodes merged 4 commits into
springfrom
4-add-bulk-delete-contacts
Mar 14, 2026
Merged

4 add bulk delete contacts#19
yamcodes merged 4 commits into
springfrom
4-add-bulk-delete-contacts

Conversation

@yamcodes

@yamcodes yamcodes commented Mar 14, 2026

Copy link
Copy Markdown
Owner

Closes #4

Summary by CodeRabbit

  • New Features
    • Added bulk delete functionality: Users can now delete multiple contacts simultaneously by providing a list of contact identifiers to the contacts endpoint, improving efficiency for managing large contact lists.

- Implement `deleteMany` method in `ContactService` to handle bulk deletion logic.
- Add `@DeleteMapping` endpoint in `ContactController` to support bulk contact removal via slugs.
- Extend `ContactRepository` with `findAllBySlugIn` query for fetching multiple contacts.
@coderabbitai

coderabbitai Bot commented Mar 14, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@yamcodes has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 18 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d209276f-3686-44e2-8b1a-00294575ce4f

📥 Commits

Reviewing files that changed from the base of the PR and between 8ea8233 and 944beff.

📒 Files selected for processing (3)
  • src/main/java/codes/yam/contacts/ContactController.java
  • src/main/java/codes/yam/contacts/ContactRepository.java
  • src/main/java/codes/yam/contacts/ContactService.java
📝 Walkthrough

Walkthrough

The changes implement a bulk delete feature by introducing a new DELETE /contacts endpoint that accepts multiple contact slugs, along with supporting service and repository methods to retrieve and delete multiple contacts in a single operation.

Changes

Cohort / File(s) Summary
Bulk Delete Feature
src/main/java/codes/yam/contacts/ContactController.java, src/main/java/codes/yam/contacts/ContactService.java, src/main/java/codes/yam/contacts/ContactRepository.java
Added new deleteManyContacts() endpoint that accepts a list of contact slugs and orchestrates bulk deletion through the service layer, which queries the repository for matching contacts and deletes them all at once.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Controller as ContactController
    participant Service as ContactService
    participant Repository as ContactRepository
    participant DB as Database

    Client->>Controller: DELETE /contacts?slugs=slug1,slug2,...
    activate Controller
    Controller->>Service: deleteMany(slugs)
    activate Service
    Service->>Repository: findAllBySlugIn(slugs)
    activate Repository
    Repository->>DB: Query contacts by slugs
    activate DB
    DB-->>Repository: Contact list
    deactivate DB
    Repository-->>Service: contacts
    deactivate Repository
    Service->>Repository: deleteAll(contacts)
    activate Repository
    Repository->>DB: Delete contacts
    activate DB
    DB-->>Repository: Deletion complete
    deactivate DB
    Repository-->>Service: void
    deactivate Repository
    Service-->>Controller: void
    deactivate Service
    Controller-->>Client: Redirect to /contacts
    deactivate Controller
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 With whiskers twitched and paws all set,
We bundle slugs in one big net,
A DELETE call, so swift and clean,
Makes many contacts cease to be seen,
Bulk operations hop with glee! 🐇

🚥 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 'add bulk delete contacts' clearly summarizes the main change—implementing bulk deletion functionality as specified in the linked issue.
Linked Issues check ✅ Passed The PR implements the core backend requirement from issue #4: a DELETE /contacts endpoint accepting slugs to delete multiple contacts. UI changes (checkboxes and bulk delete button) are not included but are noted as out of scope.
Out of Scope Changes check ✅ Passed The PR focuses solely on backend implementation (service, repository, and controller changes) for bulk deletion. No unrelated changes detected, though required UI features are absent.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 4-add-bulk-delete-contacts
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@yamcodes

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Mar 14, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

- Implement `validateEmail` endpoint in `ContactController` for real-time email validation using HTMX.
- Consolidate and simplify contact-related URL mappings for better usability.
- Refactor `findBySlug` to use `Optional` and update related methods in `ContactService`.
- Introduce `isEmailTaken` methods in `ContactService` to check email uniqueness.
- Update contact form templates with HTMX support for email validation.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/main/java/codes/yam/contacts/ContactService.java (1)

39-42: Guard bulk delete against empty input.

Line 39 should short-circuit for null/empty input so this endpoint stays a no-op instead of performing avoidable repository work.

♻️ Suggested change
  public void deleteMany(List<String> slugs) {
+    if (slugs == null || slugs.isEmpty()) return;
     var contacts = contactRepository.findAllBySlugIn(slugs);
     contactRepository.deleteAll(contacts);
  }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/codes/yam/contacts/ContactService.java` around lines 39 - 42,
The deleteMany method should short-circuit on null or empty input to avoid
unnecessary repository work: in ContactService.deleteMany(List<String> slugs)
check if slugs is null or slugs.isEmpty() (or use a utility like
CollectionUtils.isEmpty) and return immediately before calling
contactRepository.findAllBySlugIn or contactRepository.deleteAll; keep the
existing behavior when slugs contains values.
src/main/java/codes/yam/contacts/ContactController.java (1)

87-87: Remove the uncertainty note before merge.

Line 87 (// Not sure about this return...) is a lingering uncertainty comment in request-handling code; please remove it or replace it with an actionable TODO tied to a follow-up issue.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/codes/yam/contacts/ContactController.java` at line 87, Remove
the informal uncertainty comment "// Not sure about this return..." in
ContactController (request-handling method around the return statement) and
either delete it or replace it with a concise actionable TODO referencing a
follow-up issue ID (e.g., TODO: address return behavior - see ISSUE-123) so the
code no longer contains ambiguous developer notes; ensure this change is made in
the request handler method in ContactController.java that contains the return.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/main/java/codes/yam/contacts/ContactController.java`:
- Line 87: Remove the informal uncertainty comment "// Not sure about this
return..." in ContactController (request-handling method around the return
statement) and either delete it or replace it with a concise actionable TODO
referencing a follow-up issue ID (e.g., TODO: address return behavior - see
ISSUE-123) so the code no longer contains ambiguous developer notes; ensure this
change is made in the request handler method in ContactController.java that
contains the return.

In `@src/main/java/codes/yam/contacts/ContactService.java`:
- Around line 39-42: The deleteMany method should short-circuit on null or empty
input to avoid unnecessary repository work: in
ContactService.deleteMany(List<String> slugs) check if slugs is null or
slugs.isEmpty() (or use a utility like CollectionUtils.isEmpty) and return
immediately before calling contactRepository.findAllBySlugIn or
contactRepository.deleteAll; keep the existing behavior when slugs contains
values.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 597f5c5d-af45-436f-b577-e83e300eda74

📥 Commits

Reviewing files that changed from the base of the PR and between 061e0a9 and 8ea8233.

📒 Files selected for processing (3)
  • src/main/java/codes/yam/contacts/ContactController.java
  • src/main/java/codes/yam/contacts/ContactRepository.java
  • src/main/java/codes/yam/contacts/ContactService.java

@yamcodes
yamcodes merged commit 5db1e9b into spring Mar 14, 2026
@yamcodes
yamcodes deleted the 4-add-bulk-delete-contacts branch March 14, 2026 10:23
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