Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(j-s): add police case numbers to revoke indictment notification email #17385

Merged
merged 12 commits into from
Jan 7, 2025

Conversation

thorhildurt
Copy link
Member

@thorhildurt thorhildurt commented Jan 2, 2025

What

  • Asana task
  • Instead of sending "...ákæru í máli sem ekki hefur enn fengið málsnúmer" we want to add the policeCaseNumbers as stated in the task description

Why

  • To add more context to what case is being revoked

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced case notification system with improved message formatting.
    • Added support for including police case numbers in court notifications.
  • Bug Fixes

    • Corrected a typo in method name for revoke notifications.
    • Improved handling of case number references in notifications.
  • Improvements

    • More detailed and precise messaging for indictment cancellation notices.
    • Simplified message structure for revoked indictment notifications.

@thorhildurt thorhildurt requested a review from a team as a code owner January 2, 2025 12:18
Copy link
Contributor

coderabbitai bot commented Jan 2, 2025

Walkthrough

The pull request updates the notification system for judicial cases, specifically focusing on the courtRevokedIndictmentEmail message and related service methods. Key changes include simplifying the message structure by removing conditional logic and enhancing the handling of police case numbers. The modifications ensure that notifications are consistent and clear, particularly when a court case number is not available, thereby improving the overall clarity of communication regarding indictment cancellations.

Changes

File Change Summary
apps/judicial-system/backend/src/app/messages/notifications.ts Updated courtRevokedIndictmentEmail message body to simplify case number handling.
apps/judicial-system/backend/src/app/modules/case/case.service.ts Added withCourtCaseNumber: false for cases in WAITING_FOR_CANCELLATION state.
apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts Introduced caseNumber variable to consolidate case number logic in deliverIndictmentCancellationNoticeToCourt method.
apps/judicial-system/backend/src/app/modules/notification/services/caseNotification/caseNotification.service.ts Renamed sendRevodeNotificationsForIndictmentCase to sendRevokeNotificationsForIndictmentCase, updated notification methods to include courtCaseNumber.
apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendRevokedNotifications.spec.ts Added policeCaseNumbers to theCase object in test for notification sending.
apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentCancellationNoticeToCourt.spec.ts Updated test to reflect changes in notification structure including police case numbers.

Possibly related PRs

Suggested reviewers

  • unakb

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0679d82 and 33d6522.

📒 Files selected for processing (2)
  • apps/judicial-system/backend/src/app/messages/notifications.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/case.service.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/judicial-system/backend/src/app/modules/case/case.service.ts
  • apps/judicial-system/backend/src/app/messages/notifications.ts

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@thorhildurt thorhildurt changed the title J s/show police case numbers in email chore(j-s): add police case numbers to revoke indictment notification email Jan 2, 2025
@thorhildurt thorhildurt self-assigned this Jan 2, 2025
Copy link
Contributor

@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: 0

🧹 Nitpick comments (1)
apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentCancellationNoticeToCourt.spec.ts (1)

112-112: Consider enumerating all police case numbers
Right now, the test code references hardcoded policeCase1 and policeCase2 within the string. If you add more police case numbers later, you'll need to update this manually. You could dynamically join the array within the string for scalability.

- `${prosecutorsOffice} hefur afturkallað ákæru í máli ${policeCase1}, ${policeCase2}...`
+ const joinedCaseNumbers = policeCaseNumbers.join(', ')
+ `${prosecutorsOffice} hefur afturkallað ákæru í máli ${joinedCaseNumbers}...`
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 029015c and eeab192.

📒 Files selected for processing (5)
  • apps/judicial-system/backend/src/app/messages/notifications.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/case.service.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentCancellationNoticeToCourt.spec.ts (3 hunks)
  • apps/judicial-system/backend/src/app/modules/notification/services/caseNotification/caseNotification.service.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentCancellationNoticeToCourt.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/messages/notifications.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/notification/services/caseNotification/caseNotification.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/case/case.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
📓 Learnings (3)
apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts (1)
Learnt from: gudjong
PR: island-is/island.is#15393
File: apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts:28-28
Timestamp: 2024-11-12T15:15:11.835Z
Learning: The `DeliverCancellationNoticeDto` import in `apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts` is used in the `deliverIndictmentCancellationNoticeToCourt` method.
apps/judicial-system/backend/src/app/modules/notification/services/caseNotification/caseNotification.service.ts (1)
Learnt from: gudjong
PR: island-is/island.is#16452
File: apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts:1845-1854
Timestamp: 2024-11-12T15:15:11.835Z
Learning: In the `sendCaseFilesUpdatedNotifications` method within `internalNotification.service.ts`, when the `user` is a defence user, it is intended to send notifications to the prosecutor.
apps/judicial-system/backend/src/app/modules/case/case.service.ts (1)
Learnt from: gudjong
PR: island-is/island.is#15393
File: apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts:691-711
Timestamp: 2024-11-12T15:15:20.158Z
Learning: The `deliverIndictmentCancellationNoticeToCourt` method in `InternalCaseService` returns `{ delivered: false }` in case of an exception, as error handling is managed by a message queue handler.
🔇 Additional comments (16)
apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentCancellationNoticeToCourt.spec.ts (3)

28-30: Use descriptive variable naming or a shared fixture for test data
It's good to see police case numbers explicitly declared, but consider adding a comment or using shared fixtures to clarify the context of these test constants.


39-39: Nice addition of policeCaseNumbers to the case object
This clearly associates the new data with the test scenario.


96-96: Good descriptive test name
Renaming the test to focus on police case numbers makes the purpose clearer.

apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts (6)

Line range hint 28-30: Clarify intent of hardcoded test data
Same comment as in your spec file–the test constants are clear, but might be more maintainable if grouped in common test data utilities.


Line range hint 31-31: Explicitly grouping police case numbers
Bundling the two variables into one array is a good way to pass them around as a collection.


Line range hint 39-39: Adding policeCaseNumbers
Looks solid. Ensure all references handle an empty array scenario correctly.


675-678: Verify empty or large arrays
Joining the police case numbers with “, ” works fine when there's at least one item. Ensure it behaves as expected if the array is empty or has more than two items.


686-686: Passing courtCaseNumber
This code paths into the format function seamlessly. No issues found.


693-694: Inserting placeholders
The placeholders for courtCaseNumber and policeCaseNumbers are consistent with the new email template.

apps/judicial-system/backend/src/app/messages/notifications.ts (1)

842-842: Graceful fallback to policeCaseNumbers
The updated select statement elegantly handles the scenario where no court case number is provided. Great use of fallback placeholders.

apps/judicial-system/backend/src/app/modules/case/case.service.ts (1)

863-863: Confirm correct usage of withCourtCaseNumber: false
When the state is WAITING_FOR_CANCELLATION, we explicitly disable the court case number usage. Verify that no scenario requires the actual courtCaseNumber in the subsequent logic.

apps/judicial-system/backend/src/app/modules/notification/services/caseNotification/caseNotification.service.ts (5)

1442-1444: Consider handling empty arrays gracefully.
Assigning a default 'NONE' to courtCaseNumber is fine. However, for policeCaseNumbers.join(', '), ensure there's no unexpected behavior if policeCaseNumbers is empty. Either handle an empty array scenario or confirm such a case cannot occur.


1448-1448: No issues found.
This reference to courtCaseNumber aligns with the variable defined above.


1455-1456: Check for user clarity with appended police case numbers.
Including courtCaseNumber and policeCaseNumbers in the email template is a good addition. Consider verifying that these values render properly, especially when courtCaseNumber is 'NONE'.


1463-1463: Good fix of the method name typo.
Renaming sendRevodeNotificationsForIndictmentCase to sendRevokeNotificationsForIndictmentCase improves code readability and flow.


1541-1541: Method call consistency.
This change to call sendRevokeNotificationsForIndictmentCase appropriately reflects the corrected method name, ensuring consistency.

@datadog-island-is
Copy link

datadog-island-is bot commented Jan 2, 2025

Datadog Report

Branch report: j-s/show-police-case-numbers-in-email
Commit report: d632b68
Test service: judicial-system-backend

✅ 0 Failed, 21055 Passed, 0 Skipped, 18m 55.47s Total Time
⬆️ Test Sessions change in coverage: 1 increased (+0.01%)

Copy link

codecov bot commented Jan 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.65%. Comparing base (fd4a86b) to head (33d6522).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #17385   +/-   ##
=======================================
  Coverage   35.65%   35.65%           
=======================================
  Files        6939     6939           
  Lines      149151   149153    +2     
  Branches    42652    42653    +1     
=======================================
+ Hits        53180    53182    +2     
  Misses      95971    95971           
Flag Coverage Δ
api 3.33% <ø> (ø)
api-domains-auth-admin 48.49% <ø> (ø)
api-domains-communications 39.44% <ø> (ø)
application-system-api 38.75% <ø> (+<0.01%) ⬆️
application-template-api-modules 27.71% <ø> (+<0.01%) ⬆️
cms 0.39% <ø> (ø)
cms-translations 38.76% <ø> (ø)
judicial-system-api 20.23% <ø> (ø)
judicial-system-backend 55.87% <100.00%> (+<0.01%) ⬆️
judicial-system-formatters 78.52% <ø> (ø)
judicial-system-message 66.66% <ø> (ø)
judicial-system-message-handler 48.41% <ø> (ø)
judicial-system-types 41.54% <ø> (ø)
judicial-system-web 27.76% <ø> (ø)
services-user-notification 46.52% <ø> (ø)
web 2.39% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...l-system/backend/src/app/messages/notifications.ts 100.00% <ø> (ø)
...ystem/backend/src/app/modules/case/case.service.ts 88.62% <ø> (ø)
...ckend/src/app/modules/case/internalCase.service.ts 84.08% <100.00%> (+0.03%) ⬆️
...vices/caseNotification/caseNotification.service.ts 79.34% <100.00%> (+0.02%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fd4a86b...33d6522. Read the comment docs.

Copy link
Contributor

@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: 0

🧹 Nitpick comments (2)
apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendRevokedNotifications.spec.ts (1)

38-39: Add tests for multiple police case numbers.

Currently, the array only contains a single police case number. Consider adding covering test scenarios for multiple police case numbers or an empty array scenario to ensure broader coverage and robustness.

apps/judicial-system/backend/src/app/messages/notifications.ts (1)

840-842: Manage multiple police case numbers gracefully.

When courtCaseNumber is NONE, the template displays {policeCaseNumbers}. For multiple case numbers in an array, consider a format that clearly separates them (e.g., comma-separated). This will enrich the clarity of the notification and match user expectations.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eeab192 and ef5f516.

📒 Files selected for processing (2)
  • apps/judicial-system/backend/src/app/messages/notifications.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendRevokedNotifications.spec.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendRevokedNotifications.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/messages/notifications.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (1)
apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendRevokedNotifications.spec.ts (1)

54-54: Confirm consistent parameter usage.

This addition to theCase aligns well with the rest of the code. Ensure that all references in other modules (e.g., services, controllers) expect or handle this new policeCaseNumbers field appropriately.

Copy link
Contributor

@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: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ef5f516 and 2f2cd0f.

📒 Files selected for processing (4)
  • apps/judicial-system/backend/src/app/messages/notifications.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/case.service.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/notification/services/caseNotification/caseNotification.service.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/judicial-system/backend/src/app/modules/case/case.service.ts
  • apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts
🧰 Additional context used
📓 Path-based instructions (2)
apps/judicial-system/backend/src/app/messages/notifications.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/notification/services/caseNotification/caseNotification.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
📓 Learnings (1)
apps/judicial-system/backend/src/app/modules/notification/services/caseNotification/caseNotification.service.ts (1)
Learnt from: gudjong
PR: island-is/island.is#16452
File: apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts:1845-1854
Timestamp: 2024-11-12T15:15:11.835Z
Learning: In the `sendCaseFilesUpdatedNotifications` method within `internalNotification.service.ts`, when the `user` is a defence user, it is intended to send notifications to the prosecutor.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: prepare
🔇 Additional comments (2)
apps/judicial-system/backend/src/app/modules/notification/services/caseNotification/caseNotification.service.ts (2)

1446-1460: LGTM! Police case numbers are now included in the notification.

The implementation correctly:

  • Joins multiple police case numbers with commas
  • Passes the police case numbers to the email notification

1467-1467: LGTM! Fixed typo in method name.

Changed from sendRevodeNotificationsForIndictmentCase to sendRevokeNotificationsForIndictmentCase to fix the spelling.

Also applies to: 1545-1545

@thorhildurt
Copy link
Member Author

Addressed feedback and tested again both states when (1) court emails are sent, and (2) robot email are sent and both consistently contain the police case numbers in the body 👍
Screenshot 2025-01-07 at 14 00 25
Screenshot 2025-01-07 at 14 00 30
Screenshot 2025-01-07 at 14 00 34

Copy link
Member

@unakb unakb left a comment

Choose a reason for hiding this comment

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

Nice ! Looks good, there's just one comment from the rabbit that needs to be addressed, there's one place that needs to be changed after the notification string change because it's still sending in policecaseNumbers/courtCaseNumber instead of caseNumber

@thorhildurt thorhildurt added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Jan 7, 2025
@kodiakhq kodiakhq bot merged commit 994bc34 into main Jan 7, 2025
67 checks passed
@kodiakhq kodiakhq bot deleted the j-s/show-police-case-numbers-in-email branch January 7, 2025 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated:automerge (Disabled) Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants