Add ticket view link, implement custom CommentDto query, and remove c…#128
Conversation
…omment title from ticket template.
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ 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: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughReplaces a derived Spring Data finder with an explicit JPQL constructor projection returning Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
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)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/java/org/example/untitled/usercase/repository/CommentRepository.java (1)
13-16: Consider adding a stableORDER BYclause.Without an explicit
ORDER BY, the database is free to return comments in any order, which can cause comments to appear shuffled between page loads on the ticket detail view. Ordering bycreatedAt(orid) makes the conversation thread render predictably.♻️ Proposed fix
`@Query`("SELECT new org.example.untitled.usercase.dto.CommentDto(" + "c.id, c.text, c.author.id, c.author.username, c.caseEntity.id, c.createdAt) " + - "FROM Comment c WHERE c.caseEntity = :caseEntity") + "FROM Comment c WHERE c.caseEntity = :caseEntity " + + "ORDER BY c.createdAt ASC") List<CommentDto> findCommentsByCaseEntity(CaseEntity caseEntity);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/java/org/example/untitled/usercase/repository/CommentRepository.java` around lines 13 - 16, The custom query in CommentRepository (the `@Query` on findCommentsByCaseEntity producing CommentDto) lacks an ORDER BY, so results can be non-deterministic; update the JPQL to include a stable ordering (e.g., append "ORDER BY c.createdAt ASC" or "ORDER BY c.id ASC") to ensure comments are consistently returned in chronological order for rendering.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@src/main/java/org/example/untitled/usercase/repository/CommentRepository.java`:
- Around line 13-16: The JPQL query in CommentRepository uses the named
parameter :caseEntity but the repository method
findCommentsByCaseEntity(CaseEntity caseEntity) lacks the `@Param` binding; update
the method signature in CommentRepository to annotate the parameter with
`@Param`("caseEntity") so Spring Data JPA binds the named parameter reliably
(regardless of javac -parameters flag).
---
Nitpick comments:
In
`@src/main/java/org/example/untitled/usercase/repository/CommentRepository.java`:
- Around line 13-16: The custom query in CommentRepository (the `@Query` on
findCommentsByCaseEntity producing CommentDto) lacks an ORDER BY, so results can
be non-deterministic; update the JPQL to include a stable ordering (e.g., append
"ORDER BY c.createdAt ASC" or "ORDER BY c.id ASC") to ensure comments are
consistently returned in chronological order for rendering.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8eb5ca74-d4a9-451c-866f-0735a51e8f41
📒 Files selected for processing (3)
src/main/java/org/example/untitled/usercase/repository/CommentRepository.javasrc/main/resources/templates/ticket.htmlsrc/main/resources/templates/userpage.html
💤 Files with no reviewable changes (1)
- src/main/resources/templates/ticket.html
viktorlindell12
left a comment
There was a problem hiding this comment.
er bra ut och fixar det den ska, två småbuggar bara som kan vara värda att lösa om du håller med och tiden finns 1. Upload-länken i userpage.html pekar på /upload men S3Controller ligger på /tickets/upload — ger 404.
2. "Back"-länken i ticket.html går till /tickets vilket är en skyddad REST-endpoint, vanliga användare får 403. Byt till /user.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/main/resources/templates/ticket.html`:
- Around line 41-42: The Back link's security attribute currently restricts
visibility to HANDLER and SUPERVISOR but should also include ADMIN so admins can
see the link; update the anchor's sec:authorize expression (the element
rendering the Back link to "/handler") to include 'ADMIN' alongside 'HANDLER'
and 'SUPERVISOR' so it matches HandlerController's allowed roles
(HandlerController).
- Around line 43-44: The link visibility in ticket.html is insufficient; enforce
the same check server-side by adding method-level (or class-level) authorization
to the UserController (e.g., annotate the controller class UserController or its
handler method(s) that serve /user with `@PreAuthorize`("hasRole('USER')") or an
equivalent `@Secured/`@RolesAllowed annotation), import the corresponding security
annotation, and ensure method security is enabled in your security configuration
(e.g., prePostEnabled=true) so direct requests to /user are blocked for non-USER
roles.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7a7d7c08-b05a-4dc4-abd3-3f29ce698d42
📒 Files selected for processing (3)
src/main/java/org/example/untitled/usercase/repository/CommentRepository.javasrc/main/resources/templates/ticket.htmlsrc/main/resources/templates/userpage.html
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/resources/templates/userpage.html
…plate with admin role authorization
…omment title from ticket template.
Summary by CodeRabbit
New Features
Bug Fixes / Improvements