4 add bulk delete contacts - #19
Conversation
- 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.
…`ContactRepository`
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe changes implement a bulk delete feature by introducing a new Changes
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
- 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.
There was a problem hiding this comment.
🧹 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
📒 Files selected for processing (3)
src/main/java/codes/yam/contacts/ContactController.javasrc/main/java/codes/yam/contacts/ContactRepository.javasrc/main/java/codes/yam/contacts/ContactService.java
…improved readability and flexibility
Closes #4
Summary by CodeRabbit