Skip to content

Add ticket view link, implement custom CommentDto query, and remove c…#128

Merged
apaegs merged 6 commits into
mainfrom
fix/comment-repository-query
Apr 27, 2026
Merged

Add ticket view link, implement custom CommentDto query, and remove c…#128
apaegs merged 6 commits into
mainfrom
fix/comment-repository-query

Conversation

@apaegs

@apaegs apaegs commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

…omment title from ticket template.

Summary by CodeRabbit

  • New Features

    • Added "View" action button to ticket listings for convenient navigation to ticket details
  • Bug Fixes / Improvements

    • Removed redundant comment title from ticket view to streamline display
    • Comments now consistently load and display in chronological order with author and timestamp preserved
    • Role-aware navigation: back links adapt based on user role
    • "Upload file" button now navigates to the ticket upload page

@coderabbitai

coderabbitai Bot commented Apr 27, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

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

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 @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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 92d77232-a8f0-4e64-b325-b934738caaf1

📥 Commits

Reviewing files that changed from the base of the PR and between 92d51ce and 509b5a2.

📒 Files selected for processing (2)
  • src/main/java/org/example/untitled/user/controller/UserController.java
  • src/main/resources/templates/ticket.html
📝 Walkthrough

Walkthrough

Replaces a derived Spring Data finder with an explicit JPQL constructor projection returning CommentDto (ordered by creation time), updates ticket template to remove comment title and add role-guarded navigation, and adds a per-ticket "View" action on the user page linking to /tickets/{id}.

Changes

Cohort / File(s) Summary
Repository — Comment projection
src/main/java/org/example/untitled/usercase/repository/CommentRepository.java
Replaced derived finder with an explicit @Query JPQL constructor expression returning List<CommentDto>, added @Param("caseEntity") binding, ORDER BY c.createdAt ASC, and necessary imports. Review mapping of selected fields to CommentDto.
Templates — ticket page
src/main/resources/templates/ticket.html
Added Thymeleaf Spring Security extras namespace and role-guarded navigation links; removed rendering of comment.title from comment list. Verify authorization fragments and remaining comment fields.
Templates — user page
src/main/resources/templates/userpage.html
Changed upload link target to /tickets/upload and added a "View" action th:href="@{/tickets/{id}(id=${ticket.id})}" alongside existing actions. Check URL paths and button placement.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • viktorlindell12

Poem

🐰 I hopped through fields of DTO and thyme,
Snipped a title, tuned a query's rhyme,
A View appears where users roam,
Ordered comments find their home,
I nibble bugs and leave it prime. 🥕

🚥 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 accurately summarizes the main changes: adding a ticket view link, implementing a custom CommentDto query, and removing comment title from the ticket template.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/comment-repository-query

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.

@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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/java/org/example/untitled/usercase/repository/CommentRepository.java (1)

13-16: Consider adding a stable ORDER BY clause.

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 by createdAt (or id) 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5582853 and a85faf9.

📒 Files selected for processing (3)
  • src/main/java/org/example/untitled/usercase/repository/CommentRepository.java
  • src/main/resources/templates/ticket.html
  • src/main/resources/templates/userpage.html
💤 Files with no reviewable changes (1)
  • src/main/resources/templates/ticket.html

Comment thread src/main/java/org/example/untitled/usercase/repository/CommentRepository.java Outdated

@viktorlindell12 viktorlindell12 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.

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.

@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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between adc8206 and 92d51ce.

📒 Files selected for processing (3)
  • src/main/java/org/example/untitled/usercase/repository/CommentRepository.java
  • src/main/resources/templates/ticket.html
  • src/main/resources/templates/userpage.html
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/resources/templates/userpage.html

Comment thread src/main/resources/templates/ticket.html Outdated
Comment thread src/main/resources/templates/ticket.html
@apaegs
apaegs merged commit 2bdccd0 into main Apr 27, 2026
2 checks passed
@apaegs
apaegs deleted the fix/comment-repository-query branch April 27, 2026 14: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.

Add View button to user ticket list Fix: CommentRepository query fails with PropertyReferenceException

2 participants