-
Notifications
You must be signed in to change notification settings - Fork 61
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
base: main
Are you sure you want to change the base?
Conversation
…s/show-police-case-numbers-in-email
WalkthroughThe pull request focuses on enhancing the notification system for judicial cases, specifically improving how indictment cancellation notices are handled. The changes primarily involve modifying message templates, updating service methods, and refining how case numbers are referenced in notifications. The modifications aim to provide more precise and informative messaging when a court revokes an indictment, incorporating police case numbers when a court case number is not available. Changes
Sequence DiagramsequenceDiagram
participant Case
participant CaseService
participant NotificationService
participant Court
Case->>CaseService: Request indictment cancellation
CaseService->>NotificationService: Prepare notification
NotificationService->>NotificationService: Generate message with police case numbers
NotificationService->>Court: Send revocation notice
Possibly related PRs
Suggested labels
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
@@ -860,6 +860,7 @@ export class CaseService { | |||
type: MessageType.DELIVERY_TO_COURT_INDICTMENT_CANCELLATION_NOTICE, | |||
user, | |||
caseId: theCase.id, | |||
// Q: Why do we have to pass this flag? Why can't we rely on the court case numbers not being defined on the case object? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question targeting the flag withCourtCaseNumber
, which is set to false
when CaseState.WAITING_FOR_CANCELLATION
is true and I am curious to understand why we can´t simply check if the the case number field is undefined
👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is a little confusing, I'll try to explain 😄
Basically the requirement here was to send an exact copy of the e-mail that gets sent to the court when a prosecutor asks for cancellation. If a prosecutor could only ask for cancellation after the court sets a court case number, then we wouldn't need this. But we have cases where :
- Prosecutor creates case and sends to court
- Prosecutor wants to cancel case, so he asks for cancellation
- Email of cancellation is sent to the courts (with the text not including the court case number as it hasn't been set by the court yet)
- When the court opens said case, they get a modal which tells them the case has been cancelled, and in this modal they set the court case number and close the case (to store the info in Auður)
- Once they have set a court case number, a number of deliveries get pushed to the queue, including the cancellation notice
- Cancellation notice is picked up from the queue. At this point, the case actually does have a court case number, but we want to send the text that was without the court case number to the robot (so that it matches the email sent to the court)
We can discuss further offline if you want, it's quite a specific piece of logic that isn't easy to infer from just the code, maybe we should add a comment or something
There was a problem hiding this 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 hardcodedpoliceCase1
andpoliceCase2
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
📒 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 ofpoliceCaseNumbers
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
: AddingpoliceCaseNumbers
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
: PassingcourtCaseNumber
This code paths into the format function seamlessly. No issues found.
693-694
: Inserting placeholders
The placeholders forcourtCaseNumber
andpoliceCaseNumbers
are consistent with the new email template.apps/judicial-system/backend/src/app/messages/notifications.ts (1)
842-842
: Graceful fallback topoliceCaseNumbers
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 ofwithCourtCaseNumber: false
When the state isWAITING_FOR_CANCELLATION
, we explicitly disable the court case number usage. Verify that no scenario requires the actualcourtCaseNumber
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'
tocourtCaseNumber
is fine. However, forpoliceCaseNumbers.join(', ')
, ensure there's no unexpected behavior ifpoliceCaseNumbers
is empty. Either handle an empty array scenario or confirm such a case cannot occur.
1448-1448
: No issues found.
This reference tocourtCaseNumber
aligns with the variable defined above.
1455-1456
: Check for user clarity with appended police case numbers.
IncludingcourtCaseNumber
andpoliceCaseNumbers
in the email template is a good addition. Consider verifying that these values render properly, especially whencourtCaseNumber
is'NONE'
.
1463-1463
: Good fix of the method name typo.
RenamingsendRevodeNotificationsForIndictmentCase
tosendRevokeNotificationsForIndictmentCase
improves code readability and flow.
1541-1541
: Method call consistency.
This change to callsendRevokeNotificationsForIndictmentCase
appropriately reflects the corrected method name, ensuring consistency.
Datadog ReportBranch report: ✅ 0 Failed, 21072 Passed, 0 Skipped, 18m 14s Total Time |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #17385 +/- ##
=======================================
Coverage 35.68% 35.68%
=======================================
Files 6931 6931
Lines 148786 148786
Branches 42510 42508 -2
=======================================
Hits 53092 53092
Misses 95694 95694
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this 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
isNONE
, 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
📒 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 newpoliceCaseNumbers
field appropriately.
@@ -672,23 +672,26 @@ export class InternalCaseService { | |||
): Promise<DeliverResponse> { | |||
await this.refreshFormatMessage() | |||
|
|||
const courtCaseNumber = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider simplifying this so that the message just takes in a single variable called caseNumber or something along those lines, and then you can just send it straight in since there are no other changes to the string except which case number(s) are getting sent in.
The string in notifications.ts could then simply be
'{prosecutorsOffice} hefur afturkallað ákæru í máli {caseNumber}.',
where the caseNumber is decided with a const here depending on whether or not withCourtCaseNumber is true/false and the courtCaseNumber is set.
What
policeCaseNumbers
as stated in the task descriptionWhy
Checklist:
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Improvements