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 more info to new indictment robot emails #17184

Merged
merged 4 commits into from
Dec 12, 2024

Conversation

unakb
Copy link
Member

@unakb unakb commented Dec 9, 2024

Upplýsingapóstur - roboti. Taka út bandstrik í löke nr.
Upplýsingapóstur - roboti. Senda netfang sækjanda með nafni á robottann með upplýsingum um ákæru

What

Add prosecutors email address to new indictment robot mail info
Remove dashes from police case number that is sent to courts, both via robot and API

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

  • New Features

    • Enhanced delivery of indictment information to the court by including the prosecutor's email address.
    • Improved handling of police case numbers by sanitizing them before use.
  • Bug Fixes

    • Corrected the formatting of police case numbers in court case creation.
  • Tests

    • Updated test cases to reflect changes in prosecutor information and police case number formatting.

Copy link
Contributor

coderabbitai bot commented Dec 9, 2024

Walkthrough

This pull request introduces enhancements to the InternalCaseService and CourtService classes within the judicial system application. The deliverIndictmentInfoToCourt method is modified to include the prosecutor's email in the data sent to the court. Additionally, the updateIndictmentCaseWithIndictmentInfo method is updated to accept this new email field. The handling of police case numbers is refined by sanitizing the input to remove hyphens before use. Corresponding test files are updated to reflect these changes in both functionality and structure.

Changes

File Change Summary
.../case/internalCase.service.ts Enhanced deliverIndictmentInfoToCourt method to include email in the prosecutor object.
.../case/test/internalCaseController/deliverIndictmentInfoToCourt.spec.ts Updated theCase definition to include email in the prosecutor object for testing.
.../court/court.service.ts Updated updateIndictmentCaseWithIndictmentInfo method to include email in the prosecutor parameter.
.../court/test/createCourtCase.spec.ts Modified test cases to sanitize sourceNumber by removing hyphens from policeCaseNumbers.

Possibly related PRs

  • feat(j-s): Deliver defender info to robot for indictment cases #15191: This PR modifies the InternalCaseService class, specifically the deliverIndictmentInfoToCourt method, which is directly related to the changes made in the main PR regarding the handling of prosecutor information.
  • fix(j-s): Rovot Indictment Subject #15343: This PR updates the InternalCaseService class, including changes to the updateIndictmentCaseWithIndictmentInfo method, which is relevant as it also deals with the prosecutor's information being passed in the context of indictment cases.
  • fix(j-s): Court Receival Date #16903: This PR modifies the InternalCaseService class, specifically the deliverIndictmentInfoToCourt method, which aligns with the main PR's focus on enhancing the delivery of indictment information to the court.
  • feat(j-s): Deliver Confirmed Indictment Ruling to Court #17104: This PR involves the CaseService class and focuses on delivering confirmed indictment rulings to the court, which relates to the overall context of handling indictment cases and their associated information.

Suggested labels

automerge


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

@unakb unakb marked this pull request as ready for review December 9, 2024 15:26
@unakb unakb requested a review from a team as a code owner December 9, 2024 15:26
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

🧹 Outside diff range and nitpick comments (2)
apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentInfoToCourt.spec.ts (1)

57-61: LGTM! Consider using a more realistic test email domain.

The addition of the prosecutor's email property aligns with the PR objectives. While the implementation is correct, consider using a more realistic domain for the test email (e.g., @domstolar.is or similar official domain) to better reflect production scenarios.

apps/judicial-system/backend/src/app/modules/court/test/createCourtCase.spec.ts (1)

108-108: LGTM! Consider adding explicit test cases for hyphenated numbers.

The implementation correctly removes hyphens from police case numbers across all test cases. However, since this is a new requirement, consider adding specific test cases with hyphenated police case numbers to explicitly verify this behavior.

Example test case addition:

it('should remove hyphens from police case number', () => {
  const hyphenatedNumber = '123-456-789'
  policeCaseNumbers = [hyphenatedNumber]
  
  // ... test setup ...
  
  expect(mockCourtClientService.createCase).toHaveBeenCalledWith(
    courtId,
    expect.objectContaining({
      sourceNumber: '123456789'
    })
  )
})

Also applies to: 149-149, 186-186, 221-221

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 31b2fdb and 3c0fa85.

📒 Files selected for processing (4)
  • apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentInfoToCourt.spec.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/court/court.service.ts (3 hunks)
  • apps/judicial-system/backend/src/app/modules/court/test/createCourtCase.spec.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
apps/judicial-system/backend/src/app/modules/court/test/createCourtCase.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/test/internalCaseController/deliverIndictmentInfoToCourt.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/modules/court/court.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/case/internalCase.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.
🔇 Additional comments (4)
apps/judicial-system/backend/src/app/modules/court/court.service.ts (3)

339-341: LGTM: Police case number sanitization implemented correctly.

The implementation properly handles the removal of hyphens from police case numbers and includes null safety checks.

Also applies to: 350-350


575-575: LGTM: Prosecutor email field added and police case number sanitization implemented.

The changes successfully:

  1. Add the prosecutor's email field to the type definition
  2. Implement consistent police case number sanitization

Also applies to: 579-581, 585-585


575-585: Verify the implementation across the codebase.

Let's verify:

  1. All callers are updated to handle the new prosecutor email field
  2. Police case number sanitization is consistent
✅ Verification successful

Let me gather more information about the usage of this method to verify all callers.


Implementation verification completed

  • The police case number sanitization is consistent across the codebase, with all instances using the same .replace(/-/g, '') pattern
  • The updateIndictmentCaseWithIndictmentInfo method is only called from internalCase.service.ts, and the prosecutor parameter is optional, so no updates to callers are required
  • The test file correctly mocks the method call without requiring the optional prosecutor parameter
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for prosecutor email field usage
echo "Checking for prosecutor email field usage..."
rg -p "updateIndictmentCaseWithIndictmentInfo.*prosecutor.*email" apps/

# Check for police case number sanitization
echo "Checking for consistent police case number sanitization..."
rg -p "policeCaseNumber.*replace.*-" apps/

Length of output: 898


Script:

#!/bin/bash
# Check for all usages of updateIndictmentCaseWithIndictmentInfo
echo "Checking for method calls..."
rg -p "updateIndictmentCaseWithIndictmentInfo" apps/ -A 5

# Check the method definition
echo "Checking method definition..."
ast-grep --pattern 'updateIndictmentCaseWithIndictmentInfo($$$) {
  $$$
}'

Length of output: 1394

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

609-609: LGTM! Verify court service compatibility.

The addition of prosecutor's email aligns with the PR objective to enhance indictment robot emails.

Let's verify if the court service is ready to handle this new field:

✅ Verification successful

Based on the search results, I can see that the court client service has an updateCaseWithProsecutor method that handles prosecutor updates to the court, and the email field is a standard string type in user-related interfaces. The court client service implementation shows it properly handles prosecutor updates through its API. Since the court service is already set up to handle prosecutor information updates and email is a basic string field, this change should be safe.

LGTM! Court service is ready to handle prosecutor's email

The court client service has proper infrastructure to handle prosecutor updates including basic fields like email through its updateCaseWithProsecutor API endpoint.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if court service is updated to handle prosecutor email

# Search for prosecutor email handling in court service
ast-grep --pattern 'updateIndictmentCaseWithIndictmentInfo($$$) {
  $$$
  prosecutor?: {
    $$$
    email?: $_
    $$$
  }
  $$$
}'

# Backup: Search using ripgrep
rg -A 5 'updateIndictmentCaseWithIndictmentInfo.*prosecutor.*email'

Length of output: 204


Script:

#!/bin/bash
# Let's try a broader search to find court service interfaces and types
# Search for court service files
fd -t f "court.*\.(ts|js)" 

# Search for any interface or type definitions related to indictment cases
rg -A 10 "interface.*Indictment|type.*Indictment"

# Search for prosecutor type definitions
rg -A 5 "interface.*Prosecutor|type.*Prosecutor"

# Search for court API endpoints or services handling indictment
rg -A 5 "updateIndictment|createIndictment"

Length of output: 67004


Script:

#!/bin/bash
# Let's search for court client service and interfaces to check email handling
# Search for court client service
rg -A 10 "class.*CourtClient" libs/judicial-system/court-client/src/lib/courtClient.service.ts

# Search for interfaces or types related to indictment updates in court
rg -A 10 "interface.*UpdateIndictment|type.*UpdateIndictment" libs/judicial-system/types/src/lib/

# Search for prosecutor type definitions
rg -A 5 "interface.*Prosecutor|type.*Prosecutor" libs/judicial-system/types/src/lib/

Length of output: 1717


Script:

#!/bin/bash
# Let's check the court client service implementation for email handling
rg -A 10 "updateCaseWithProsecutor|updateIndictmentCase" libs/judicial-system/court-client/src/lib/

# Check for email-related types and interfaces
rg -A 5 "email.*:.*string" libs/judicial-system/types/src/lib/

# Check for prosecutor-related types in court client
rg -A 5 "prosecutor.*:.*{" libs/judicial-system/court-client/src/lib/

Length of output: 7642

Copy link

codecov bot commented Dec 9, 2024

Codecov Report

Attention: Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 35.76%. Comparing base (b2c44ee) to head (deb2d4a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...tem/backend/src/app/modules/court/court.service.ts 40.00% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17184      +/-   ##
==========================================
- Coverage   35.76%   35.76%   -0.01%     
==========================================
  Files        6931     6931              
  Lines      147974   147965       -9     
  Branches    42171    42167       -4     
==========================================
- Hits        52930    52925       -5     
+ Misses      95044    95040       -4     
Flag Coverage Δ
api 3.33% <ø> (ø)
api-domains-auth-admin 48.49% <ø> (ø)
api-domains-communications 39.42% <ø> (ø)
application-system-api 38.75% <ø> (-0.02%) ⬇️
application-template-api-modules 27.79% <ø> (-0.03%) ⬇️
cms 0.40% <ø> (ø)
cms-translations 38.76% <ø> (ø)
judicial-system-api 20.16% <ø> (ø)
judicial-system-backend 55.87% <40.00%> (-0.01%) ⬇️
services-user-notification 46.54% <ø> (-0.04%) ⬇️
web 2.43% <ø> (ø)

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

Files with missing lines Coverage Δ
...ckend/src/app/modules/case/internalCase.service.ts 84.42% <ø> (ø)
...tem/backend/src/app/modules/court/court.service.ts 39.47% <40.00%> (-0.09%) ⬇️

... and 4 files with indirect coverage changes


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 b2c44ee...deb2d4a. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Dec 9, 2024

Datadog Report

All test runs a7d9961 🔗

11 Total Test Services: 0 Failed, 10 Passed
➡️ Test Sessions change in coverage: 29 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 3.28s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 14.5s 1 no change Link
api-domains-communications 0 0 0 5 0 38.8s 1 no change Link
api-domains-license-service 0 0 0 0 0 479.81ms 1 no change Link
application-system-api 0 0 0 46 0 2m 18.4s 1 no change Link
application-template-api-modules 0 0 0 118 0 2m 5.19s 1 no change Link
cms-translations 0 0 0 3 0 29.69s 1 no change Link
judicial-system-api 0 0 0 61 0 7.29s 1 no change Link
judicial-system-backend 0 0 0 21311 0 17m 52.92s 1 no change Link
services-user-notification 0 0 0 51 0 1m 29.49s 1 no change Link

@oddsson oddsson added the automerge Merge this PR as soon as all checks pass label Dec 11, 2024
@kodiakhq kodiakhq bot merged commit e0e74ca into main Dec 12, 2024
64 checks passed
@kodiakhq kodiakhq bot deleted the j-s/robot-indictment-info-additions branch December 12, 2024 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants