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

feat(j-s): Display service status #16177

Merged
merged 85 commits into from
Oct 7, 2024
Merged

feat(j-s): Display service status #16177

merged 85 commits into from
Oct 7, 2024

Conversation

oddsson
Copy link
Member

@oddsson oddsson commented Sep 26, 2024

Display service status

Asana

What

We need to show the status of a subpoena service in RVG. This PR implements that. This info comes from RLS and we fetch it from them but we also save a copy in our db to display, just in case the connection ever goes down.

Why

Judges and prosecutors need to see the status of the service.

Screenshots / Gifs

Failed

Screenshot 2024-10-03 at 14 57 03

Expired

Screenshot 2024-10-03 at 14 58 18

Success - In person

Screenshot 2024-10-03 at 15 00 02

Success - To defender

Screenshot 2024-10-03 at 15 02 26

Success - island.is

Screenshot 2024-10-03 at 15 03 27

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 the method for updating subpoena information to include detailed defender information.
    • Introduced validation for defender choices and national IDs to improve data integrity.
    • Added a new serviceStatus property to better reflect the status of subpoenas.
    • Exported the SubpoenaModule for improved accessibility in the application.
  • Enhancements

    • Improved organization and clarity in handling defender information and service status during updates.
    • Updated the structure of the data sent in PATCH requests for better encapsulation.
    • Integrated the SubpoenaModule into the PoliceModule for enhanced functionality.
  • Bug Fixes

    • Resolved issues related to the retrieval and handling of lawyer information.
  • Documentation

    • Updated import statements for better clarity on dependencies used in the application.

Copy link
Contributor

coderabbitai bot commented Sep 26, 2024

Walkthrough

The changes in this pull request modify the AppService class in the app.service.ts file, specifically the updateSubpoenaInfo method. The import statement is updated to include the ServiceStatus type. The method's logic is restructured to initialize a defenderInfo object and directly reference properties from updateSubpoena. Validation for defenderChoice and defenderNationalId is updated, and the construction of the serviceStatus variable is added. The updateToSend object is created for the PATCH request, replacing the previous updatesToSend object. Additionally, the UpdateSubpoenaDto class in updateSubpoena.dto.ts is modified to remove the acknowledged property, add serviceStatus and serviceDate, and rename registeredBy to servedBy. The PoliceModule now imports the SubpoenaModule, and the SubpoenaModule is exported from the index.ts file.

Changes

File Change Summary
apps/judicial-system/xrd-api/src/app/app.service.ts Modified updateSubpoenaInfo method: added ServiceStatus import, restructured logic to initialize defenderInfo, updated validation, and created updateToSend object.
apps/judicial-system/backend/src/app/modules/subpoena/dto/updateSubpoena.dto.ts Updated UpdateSubpoenaDto: removed acknowledged, added serviceStatus and serviceDate, renamed registeredBy to servedBy.
apps/judicial-system/backend/src/app/modules/police/police.module.ts Updated PoliceModule to import SubpoenaModule.
apps/judicial-system/backend/src/app/modules/subpoena/index.ts Added export for SubpoenaModule.
apps/judicial-system/backend/src/app/modules/police/test/createTestingPoliceModule.ts Enhanced testing setup: added SubpoenaService import, updated jest.mock, and included SubpoenaService in providers array.

Possibly related PRs

  • feat(j-s): API endpoint to update subpoena #15051: This PR introduces new API endpoints related to subpoenas, including setting the defense choice, which is directly relevant to the changes made in the main PR regarding the handling of defender information.
  • feat(j-s): Update subpoena dto and send multiple files #16209: This PR updates the UpdateSubpoenaDto to include new properties related to the defender's information, which aligns with the changes in the main PR that also modifies how defender information is structured and sent.
  • feat(j-s): Store Subpoena PDF and HASH #16235: This PR enhances the functionality for storing subpoenas, including the addition of a hash for verification, which relates to the overall management of subpoenas discussed in the main PR.
  • fix(j-s): Defender Subpoena #16229: This PR addresses the retrieval and handling of subpoena PDFs, which is relevant to the updates made in the main PR regarding how subpoenas are processed and updated.

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.

Copy link

codecov bot commented Sep 26, 2024

Codecov Report

Attention: Patch coverage is 20.11173% with 143 lines in your changes missing coverage. Please review.

Project coverage is 36.87%. Comparing base (f1b145f) to head (915d5cd).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...onents/ServiceAnnouncement/ServiceAnnouncement.tsx 7.40% 50 Missing ⚠️
...m/backend/src/app/modules/police/police.service.ts 13.88% 31 Missing ⚠️
...src/app/modules/defendant/models/subpoena.model.ts 0.00% 14 Missing ⚠️
.../app/modules/police/models/subpoenaStatus.model.ts 0.00% 13 Missing ⚠️
...stem/api/src/app/modules/police/police.resolver.ts 0.00% 10 Missing ⚠️
...src/app/modules/police/dto/subpoenaStatus.input.ts 0.00% 7 Missing ⚠️
...al-system/web/src/utils/hooks/useSubpoena/index.ts 20.00% 4 Missing ⚠️
...ackend/src/app/modules/police/police.controller.ts 62.50% 3 Missing ⚠️
...src/routes/Court/Indictments/Overview/Overview.tsx 0.00% 3 Missing ⚠️
...tem/api/src/app/modules/backend/backend.service.ts 0.00% 2 Missing ⚠️
... and 4 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16177      +/-   ##
==========================================
- Coverage   36.89%   36.87%   -0.03%     
==========================================
  Files        6791     6796       +5     
  Lines      140401   140568     +167     
  Branches    39925    39981      +56     
==========================================
+ Hits        51807    51836      +29     
- Misses      88594    88732     +138     
Flag Coverage Δ
judicial-system-api 18.22% <12.72%> (-0.08%) ⬇️
judicial-system-audit-trail 69.19% <100.00%> (+0.08%) ⬆️
judicial-system-backend 55.19% <44.61%> (-0.05%) ⬇️
judicial-system-formatters 79.93% <100.00%> (+0.16%) ⬆️
judicial-system-message 67.12% <ø> (ø)
judicial-system-message-handler 48.17% <ø> (ø)
judicial-system-scheduler 69.36% <100.00%> (+0.18%) ⬆️
judicial-system-types 47.77% <0.00%> (-0.58%) ⬇️
judicial-system-web 27.95% <9.23%> (-0.09%) ⬇️

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 85.12% <ø> (ø)
...tem/backend/src/app/modules/event/event.service.ts 31.37% <ø> (ø)
...p/modules/police/test/createTestingPoliceModule.ts 100.00% <100.00%> (ø)
...src/app/modules/subpoena/dto/updateSubpoena.dto.ts 100.00% <100.00%> (ø)
.../src/app/modules/subpoena/models/subpoena.model.ts 84.61% <100.00%> (+2.00%) ⬆️
apps/judicial-system/web/messages/Core/errors.ts 100.00% <ø> (ø)
...ServiceAnnouncement/ServiceAnnouncement.strings.ts 100.00% <100.00%> (ø)
...l-system/audit-trail/src/lib/auditTrail.service.ts 96.84% <100.00%> (+0.03%) ⬆️
libs/judicial-system/types/src/index.ts 100.00% <100.00%> (ø)
libs/judicial-system/types/src/lib/defendant.ts 100.00% <100.00%> (ø)
... and 14 more

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 f1b145f...915d5cd. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Sep 26, 2024

Datadog Report

All test runs f4361bf 🔗

9 Total Test Services: 0 Failed, 9 Passed
🔻 Test Sessions change in coverage: 3 decreased, 4 increased, 5 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
judicial-system-api 0 0 0 57 0 6.2s 1 decreased (-0.01%) Link
judicial-system-backend 0 0 0 21219 0 18m 33.94s 1 increased (+0.03%) Link
judicial-system-formatters 0 0 0 38 0 5.33s 1 increased (+0.12%) Link
judicial-system-message 0 0 0 32 0 11.36s 1 no change Link
judicial-system-message-handler 0 0 0 4 0 3.72s 1 no change Link
judicial-system-scheduler 0 0 0 4 0 4.01s 1 increased (+0.17%) Link
judicial-system-types 0 0 0 23 0 6.98s 1 decreased (-0.68%) Link
judicial-system-web 0 0 0 338 0 1m 6.51s 1 decreased (-0.1%) Link
judicial-system-xrd-api 0 0 0 6 0 5.01s 1 increased (+0.14%) Link

🔻 Code Coverage Decreases vs Default Branch (3)

  • judicial-system-types - jest 51.49% (-0.68%) - Details
  • judicial-system-web - jest 32.29% (-0.1%) - Details
  • judicial-system-api - jest 19.66% (-0.01%) - Details

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: 3

🧹 Outside diff range and nitpick comments (2)
apps/judicial-system/web/src/utils/hooks/useSubpoena/getSubpoenaStatus.graphql (1)

3-8: LGTM: Comprehensive field selection for subpoena status.

The selected fields (serviceStatus, servedBy, comment, serviceDate, defenderNationalId) provide a comprehensive view of the subpoena status, aligning well with the PR objectives.

Consider adding a __typename field to the query. This can be helpful for client-side type checking and debugging, especially if you're using Apollo Client or a similar GraphQL client that supports automatic cache updates.

You could add the __typename field like this:

 query SubpoenaStatus($input: SubpoenaStatusQueryInput!) {
   subpoenaStatus(input: $input) {
+    __typename
     serviceStatus
     servedBy
     comment
     serviceDate
     defenderNationalId
   }
 }
apps/judicial-system/api/src/app/modules/police/models/subpoenaStatus.model.ts (1)

10-20: LGTM with suggestions: Optional fields are well-defined.

The servedBy, comment, serviceDate, and defenderNationalId fields are correctly decorated for GraphQL, set as readonly and optional, which is consistent with their nullable status in the GraphQL schema.

Consider using more specific types for improved type safety:

  • For serviceDate, you might want to use a Date type instead of string.
  • For defenderNationalId, you could create a custom type (e.g., NationalId) to enforce a specific format.

Example:

@Field(() => GraphQLISODateTime, { nullable: true })
readonly serviceDate?: Date

@Field(() => NationalId, { nullable: true })
readonly defenderNationalId?: NationalId

This would require defining GraphQLISODateTime and NationalId types, but it would provide stronger type checking and potentially better GraphQL schema documentation.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4060591 and fa1b71e.

📒 Files selected for processing (4)
  • apps/judicial-system/api/src/app/modules/police/models/subpoenaStatus.model.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/police/police.service.ts (4 hunks)
  • apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.tsx (1 hunks)
  • apps/judicial-system/web/src/utils/hooks/useSubpoena/getSubpoenaStatus.graphql (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
apps/judicial-system/api/src/app/modules/police/models/subpoenaStatus.model.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/police/police.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/web/src/components/ServiceAnnouncement/ServiceAnnouncement.tsx (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/web/src/utils/hooks/useSubpoena/getSubpoenaStatus.graphql (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 (11)
apps/judicial-system/web/src/utils/hooks/useSubpoena/getSubpoenaStatus.graphql (1)

1-2: LGTM: Query structure and input are well-defined.

The SubpoenaStatus query is correctly structured with a non-nullable input of type SubpoenaStatusQueryInput. This ensures that the necessary data is always provided when querying for subpoena status.

apps/judicial-system/api/src/app/modules/police/models/subpoenaStatus.model.ts (4)

1-3: LGTM: Imports and file structure are correct.

The imports are properly structured, and the file is correctly placed within the NextJS application structure. The use of @nestjs/graphql demonstrates proper integration with GraphQL in a NestJS application.


5-6: LGTM: Class definition and decorator are correct.

The SubpoenaStatus class is properly defined with the @ObjectType() decorator, indicating a GraphQL object type. The class is correctly exported and follows the PascalCase naming convention, adhering to TypeScript best practices.


7-8: LGTM: serviceStatus field is well-defined.

The serviceStatus field is correctly decorated for GraphQL, set as readonly for immutability, and uses a custom type for improved type safety. The non-nullable definition is appropriate for a required field.


1-21: Overall, excellent implementation of the SubpoenaStatus model.

This file successfully defines the SubpoenaStatus GraphQL object type, adhering to NextJS and TypeScript best practices. It demonstrates good use of decorators, type safety, and immutability. The structure and naming conventions are appropriate, and the code is clean and readable.

The suggestions for more specific types for serviceDate and defenderNationalId are minor improvements that could enhance type safety and schema documentation, but they're not critical issues.

This implementation aligns well with the PR objectives of displaying service status in the RVG system.

apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.tsx (2)

1-74: LGTM: Well-structured imports and helper functions

The imports, helper functions, and error handling are well-organized and follow TypeScript and React best practices. The code is clean and easy to understand.


76-80: LGTM: Well-defined props interface

The ServiceAnnouncementProps interface is correctly defined and follows the suggested naming convention. The props are appropriately typed.

apps/judicial-system/backend/src/app/modules/police/police.service.ts (4)

26-30: LGTM: New imports for subpoena functionality.

The new imports are correctly placed and follow TypeScript best practices. They appropriately introduce the necessary types and services for the new subpoena functionality.

Also applies to: 37-38


131-142: Consider refining the subpoenaStructure definition.

The subpoenaStructure is well-defined using Zod for runtime type checking. However, consider the following improvements:

  1. Some fields might benefit from being non-nullable if they are always expected to have a value.
  2. The property name prosecutedConfirmedSubpoenaThroughIslandis is unusually long. Consider shortening it or breaking it into more manageable parts.

151-152: LGTM: Proper injection of SubpoenaService.

The SubpoenaService is correctly injected into the constructor using @Inject and forwardRef. This follows the established pattern in the class and adheres to dependency injection best practices.


339-416: 🛠️ Refactor suggestion

Improve readability and error handling in getSubpoenaStatus.

The getSubpoenaStatus method is well-structured and follows the established error handling pattern. However, consider the following improvements:

  1. Refactor the complex nested ternary operator for serviceStatus (lines 361-370) into a more readable structure, such as a switch statement or a separate function.

  2. Update the error message in the postErrorEvent call (line 401) from 'Failed to get subpoena' to 'Failed to get subpoena status' for clarity.

Apply this refactored code for the serviceStatus determination:

-              serviceStatus: response.deliveredToLawyer
-                ? ServiceStatus.DEFENDER
-                : response.prosecutedConfirmedSubpoenaThroughIslandis
-                ? ServiceStatus.ELECTRONICALLY
-                : response.deliveredOnPaper || response.delivered === true
-                ? ServiceStatus.IN_PERSON
-                : response.acknowledged === false
-                ? ServiceStatus.FAILED
-                : // TODO: handle expired
-                  undefined,
+              serviceStatus: (() => {
+                if (response.deliveredToLawyer) return ServiceStatus.DEFENDER;
+                if (response.prosecutedConfirmedSubpoenaThroughIslandis) return ServiceStatus.ELECTRONICALLY;
+                if (response.deliveredOnPaper || response.delivered === true) return ServiceStatus.IN_PERSON;
+                if (response.acknowledged === false) return ServiceStatus.FAILED;
+                // TODO: handle expired
+                return undefined;
+              })(),

And update the error message:

-          'Failed to get subpoena',
+          'Failed to get subpoena status',

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: 4

🧹 Outside diff range and nitpick comments (3)
apps/judicial-system/xrd-api/src/app/dto/subpoena.dto.ts (2)

23-26: LGTM! Consider adding date-time format validation.

The addition of the servedAt property is well-implemented with proper decorators for optional status, string validation, and API documentation.

To enhance data integrity, consider adding a date-time format validation. You can use the @IsISO8601() decorator from class-validator:

 @IsOptional()
 @IsString()
+@IsISO8601()
 @ApiProperty({ type: String, required: false })
 servedAt?: string

This ensures that the servedAt string adheres to the ISO 8601 date-time format.


Line range hint 1-55: Great overall code quality. Minor suggestion for import organization.

The code demonstrates excellent adherence to TypeScript best practices, effective use of decorators for validation and API documentation, and proper implementation of the DTO pattern. This aligns well with NextJS best practices and ensures type safety and clear API structure.

For improved readability and consistency, consider organizing the import statements. Group them by external libraries, then internal modules, separated by a blank line:

import { IsBoolean, IsEnum, IsOptional, IsString } from 'class-validator'
import { ApiProperty } from '@nestjs/swagger'

import { DefenderChoice } from '@island.is/judicial-system/types'

This minor change enhances code organization and follows common TypeScript/JavaScript import conventions.

apps/judicial-system/xrd-api/src/app/app.service.ts (1)

146-156: Ensure correct inclusion of defender information

When constructing updateToSend, the use of defenderInfo.defenderName || undefined ensures that only defined values are sent. If you implement the earlier suggestion to initialize defenderInfo properties as undefined, the || undefined checks may become unnecessary.

Apply this diff if you have initialized defenderInfo properties as undefined:

          defenderName: defenderInfo.defenderName || undefined,
          defenderEmail: defenderInfo.defenderEmail || undefined,
          defenderPhoneNumber: defenderInfo.defenderPhoneNumber || undefined,

Can be simplified to:

          defenderName: defenderInfo.defenderName,
          defenderEmail: defenderInfo.defenderEmail,
          defenderPhoneNumber: defenderInfo.defenderPhoneNumber,
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between fa1b71e and 37b3077.

📒 Files selected for processing (2)
  • apps/judicial-system/xrd-api/src/app/app.service.ts (3 hunks)
  • apps/judicial-system/xrd-api/src/app/dto/subpoena.dto.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
apps/judicial-system/xrd-api/src/app/app.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/xrd-api/src/app/dto/subpoena.dto.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/xrd-api/src/app/dto/subpoena.dto.ts (1)
Learnt from: oddsson
PR: island-is/island.is#16177
File: apps/judicial-system/backend/src/app/modules/subpoena/dto/updateSubpoena.dto.ts:16-16
Timestamp: 2024-10-04T15:11:19.318Z
Learning: In the TypeScript file `apps/judicial-system/xrd-api/src/app/dto/subpoena.dto.ts`, the property is `servedBy`, not `registeredBy`. It is correctly named, and no renaming is necessary.
🔇 Additional comments (4)
apps/judicial-system/xrd-api/src/app/dto/subpoena.dto.ts (1)

Line range hint 1-55: Verify the impact of removing deliveryInvalidated.

The deliveryInvalidated property has been removed from the UpdateSubpoenaDto class. While this aligns with the PR objective of updating the subpoena service status display, we need to ensure this removal doesn't negatively impact existing functionality.

Please run the following script to check for any remaining usage of deliveryInvalidated:

If any usages are found, please update those occurrences accordingly or provide a rationale for keeping the property removed.

✅ Verification successful

Action Required: Enhance the search for deliveryInvalidated usage.

Please run the following script to thoroughly check for any remaining usage of deliveryInvalidated across the codebase:


Action Required: Perform a comprehensive search for deliveryInvalidated usage across all files.

Please run the following script to thoroughly check for any remaining usage of deliveryInvalidated in the codebase:


Verified: Removal of deliveryInvalidated does not impact the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of deliveryInvalidated in the codebase

# Search for deliveryInvalidated in TypeScript and JavaScript files
echo "Searching for deliveryInvalidated usage:"
rg --type-add 'script:*.{ts,js}' -t script 'deliveryInvalidated'

# Search for any TODO or FIXME comments related to deliveryInvalidated
echo "\nSearching for TODO or FIXME comments related to deliveryInvalidated:"
rg --type-add 'script:*.{ts,js}' -t script -e 'TODO.*deliveryInvalidated' -e 'FIXME.*deliveryInvalidated'

Length of output: 414


Script:

# 
#!/bin/bash
# Description: Comprehensive search for any remaining usage of deliveryInvalidated in the codebase

echo "Performing a case-insensitive search for deliveryInvalidated usage in TypeScript, JavaScript, and related files:"
rg -i --type-add 'scripts:*.{ts,js,tsx,jsx}' -t scripts 'deliveryInvalidated'

echo -e "\nSearching for TODO or FIXME comments related to deliveryInvalidated, case-insensitive:"
rg -i --type-add 'scripts:*.{ts,js,tsx,jsx}' -t scripts -e 'TODO.*deliveryInvalidated' -e 'FIXME.*deliveryInvalidated'

Length of output: 622


Script:

# 
#!/bin/bash
# Description: Comprehensive search for any remaining usage of deliveryInvalidated in the codebase without file type restrictions

echo "Performing a case-insensitive search for 'deliveryInvalidated' across all files:"
rg -i 'deliveryInvalidated'

echo -e "\nSearching for TODO or FIXME comments related to 'deliveryInvalidated', case-insensitive:"
rg -i -e 'TODO.*deliveryInvalidated' -e 'FIXME.*deliveryInvalidated'

Length of output: 474

apps/judicial-system/xrd-api/src/app/app.service.ts (3)

19-19: Import statement is appropriate and necessary

The addition of ServiceStatus to the import statement is correct, as it is used later in the code for defining the serviceStatus variable.


106-107: Validation logic is correct

The condition correctly ensures that when defenderChoice is DefenderChoice.CHOOSE, a defenderNationalId must be provided. This validation will prevent incomplete data from being processed.


167-167: Request body is correctly constructed

The updateToSend object is properly serialized and included in the request body. This ensures that all necessary data is sent in the PATCH request.

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: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 37b3077 and 995e2bc.

📒 Files selected for processing (1)
  • apps/judicial-system/xrd-api/src/app/app.service.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
apps/judicial-system/xrd-api/src/app/app.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."
🔇 Additional comments (2)
apps/judicial-system/xrd-api/src/app/app.service.ts (2)

19-19: Import of ServiceStatus is appropriate

The addition of ServiceStatus to the imports from @island.is/judicial-system/types is necessary for determining the service status in the updated logic.


110-117: Validation logic is correctly implemented

The validation ensures that when defenderChoice is CHOOSE, a defenderNationalId must be provided. Throwing a BadRequestException in this scenario is appropriate and ensures data integrity.

@unakb unakb added the automerge Merge this PR as soon as all checks pass label Oct 6, 2024
@unakb unakb removed the automerge Merge this PR as soon as all checks pass label Oct 6, 2024
@unakb unakb added the automerge Merge this PR as soon as all checks pass label Oct 6, 2024
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/police/test/createTestingPoliceModule.ts (2)

24-24: LGTM: SubpoenaService correctly mocked

The SubpoenaService is properly mocked using jest.mock, which is consistent with the mocking of other services in this file. This ensures that SubpoenaService will be mocked during tests.

For consistency, consider moving this mock call to be grouped with the other service mocks (e.g., after line 21).


Line range hint 15-41: Overall: Good enhancement of the testing module

The changes to include SubpoenaService in the testing module are well-implemented and consistent with the existing pattern for other services. This enhancement allows for more comprehensive testing of the police module's functionality, which is crucial for maintaining code quality.

To further improve the module's organization, consider grouping all service-related imports, mocks, and provider entries together. This could enhance readability and make future additions more straightforward.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 684c512 and 915d5cd.

📒 Files selected for processing (1)
  • apps/judicial-system/backend/src/app/modules/police/test/createTestingPoliceModule.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
apps/judicial-system/backend/src/app/modules/police/test/createTestingPoliceModule.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 (2)
apps/judicial-system/backend/src/app/modules/police/test/createTestingPoliceModule.ts (2)

15-15: LGTM: SubpoenaService import added correctly

The import statement for SubpoenaService is correctly added and follows TypeScript best practices. This import is necessary for including SubpoenaService in the testing module.


41-41: LGTM: SubpoenaService added to providers

SubpoenaService is correctly added to the providers array, allowing it to be injected into other components during testing. This is a necessary step for including the service in the testing module.

To ensure this addition is utilized, let's verify if SubpoenaService is being used in the PoliceService or PoliceController. Run the following script:

✅ Verification successful

Verified: SubpoenaService is utilized correctly

SubpoenaService is properly added to the providers array and is being used in PoliceService as intended. No issues were found regarding its usage in PoliceController.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if SubpoenaService is used in PoliceService or PoliceController

# Search for SubpoenaService usage in PoliceService
echo "Checking PoliceService for SubpoenaService usage:"
rg "SubpoenaService" apps/judicial-system/backend/src/app/modules/police/police.service.ts

# Search for SubpoenaService usage in PoliceController
echo "Checking PoliceController for SubpoenaService usage:"
rg "SubpoenaService" apps/judicial-system/backend/src/app/modules/police/police.controller.ts

Length of output: 566

@kodiakhq kodiakhq bot merged commit 8594e56 into main Oct 7, 2024
36 checks passed
@kodiakhq kodiakhq bot deleted the j-s/show-subpoena-status branch October 7, 2024 08:21
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.

3 participants