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): Separate requested defender info from actual assigned defender #16393

Merged
merged 4 commits into from
Oct 16, 2024

Conversation

unakb
Copy link
Member

@unakb unakb commented Oct 14, 2024

Afstaða til verjanda - birta í gáttinni

What

Store requested defender information separated from the actual assigned defender

Why

Because although the defendant requests something, the judge still has the final say on the actual choice and needs to accept a requested defender before the defender gets access to the case.

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

    • Added new properties for requested defender information in various models and data transfer objects.
    • Updated GraphQL queries to include new fields for defendants.
    • Introduced alert messages for defender choice in the Advocates component.
  • Bug Fixes

    • Enhanced handling of defender information in the application.
  • Documentation

    • Added new localization strings for defender choice alerts.

@unakb unakb requested a review from a team as a code owner October 14, 2024 20:44
Copy link
Contributor

coderabbitai bot commented Oct 14, 2024

Walkthrough

The changes in this pull request involve updates to the Defendant model and related components within the judicial system application. New properties for requested defender information have been added to various classes and data transfer objects (DTOs). Additionally, a migration script has been created to modify the database schema, and updates have been made to the GraphQL queries and frontend components to accommodate these changes.

Changes

File Change Summary
apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts Added properties: requestedDefenderChoice, requestedDefenderNationalId, requestedDefenderName to Defendant class.
apps/judicial-system/backend/migrations/20241011090000-update-defendant.js Migration script to add columns: requested_defender_choice, requested_defender_national_id, requested_defender_name to defendant table. Includes methods up and down for schema changes.
apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts Added properties: requestedDefenderChoice, requestedDefenderNationalId, requestedDefenderName to UpdateDefendantDto class.
apps/judicial-system/backend/src/app/modules/subpoena/dto/updateSubpoena.dto.ts Added properties: requestedDefenderChoice, requestedDefenderNationalId, requestedDefenderName to UpdateSubpoenaDto class.
apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts Updated update method to include new properties in UpdateSubpoenaDto.
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/internal/internalCase.response.ts Updated Defendant interface to include: requestedDefenderChoice, requestedDefenderNationalId, requestedDefenderName.
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/internal/internalDefendant.response.ts Added properties: requestedDefenderChoice, requestedDefenderNationalId, requestedDefenderName to InternalDefendantResponse class.
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts Updated properties: defenderChoice and defenderName replaced with requestedDefenderChoice and requestedDefenderName in SubpoenaResponse class.
apps/judicial-system/web/src/components/FormProvider/case.graphql Added fields: requestedDefenderChoice, requestedDefenderNationalId, requestedDefenderName to Case GraphQL query.
apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.strings.ts Added new messages: defenderChoiceAlertTitle, defenderChoiceAlertMessage.
apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.tsx Updated to display alert messages for defendants with a requestedDefenderChoice.
apps/judicial-system/xrd-api/src/app/app.service.ts Modified to replace defenderInfo object with single variable defenderName, updating response handling for subpoena to reference new properties.

Possibly related PRs

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.

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

🧹 Outside diff range and nitpick comments (9)
apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts (2)

81-82: LGTM: New field requestedDefenderNationalId added correctly

The addition of requestedDefenderNationalId is correct and aligns with the PR objective. It's properly typed as a nullable string and correctly decorated for GraphQL.

Consider adding a comment or using a more specific type (e.g., NationalId) if there's a standard format for national IDs in your system. This could enhance type safety and self-documentation.


78-85: Overall changes align well with PR objective

The additions of requestedDefenderChoice, requestedDefenderNationalId, and requestedDefenderName effectively implement the PR objective of separating requested defender information from the actual assigned defender. These changes maintain consistency with the existing code structure and complement the existing defender-related fields.

To fully implement this feature:

  1. Ensure that corresponding changes are made in related components (e.g., services, resolvers) to handle these new fields.
  2. Update any relevant database schemas or migrations.
  3. Modify the frontend to display and manage this new information.
  4. Add or update unit tests to cover these new fields.
  5. Update the documentation to reflect these changes in the Defendant model.
apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts (1)

140-155: Consider grouping related properties for improved readability

The implementation of the new properties is correct and aligns well with the PR objectives. However, to enhance code organization and maintainability, consider grouping related properties together. For example, you could place all defender-related properties (both requested and assigned) in one section of the class.

This is a minor suggestion and doesn't affect the functionality, but it could improve code readability in the long term.

apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.strings.ts (1)

77-89: Well-structured localization additions with room for minor improvements

The new messages defenderChoiceAlertTitle and defenderChoiceAlertMessage are well-integrated into the existing localization structure. They follow best practices for NextJS and react-intl usage, including proper namespacing of IDs and providing descriptions for maintainability.

The use of a select statement in defenderChoiceAlertMessage is particularly good for handling various scenarios flexibly.

Suggestions for improvement:

  1. Consider adding English translations in comments for non-Icelandic speakers, to improve code readability and maintainability.
  2. In the select statement of defenderChoiceAlertMessage, consider using lowercase keys for better readability (e.g., waive instead of WAIVE).

Example of adding English translation comment:

defenderChoiceAlertTitle: {
  id: 'judicial.system.core:court_indictments.advocates.defender_choice_alert_title',
  defaultMessage: 'Val á verjanda - {defendantName}',
  // English: "Choice of defender - {defendantName}"
  description:
    'Notaður sem texti þegar ákærði hefur valið verjanda í dómaraflæði í ákærum.',
  // English: "Used as text when the defendant has chosen a defender in the court flow in indictments."
},
apps/judicial-system/xrd-api/src/app/app.service.ts (2)

99-99: LGTM! Consider using const assertion for type safety.

The simplification of defender information aligns well with the PR objective. To further improve type safety, consider using a const assertion:

let defenderName = undefined as string | undefined;

This ensures that defenderName can only be assigned string or undefined values throughout the function.


144-146: LGTM! Consider updating the SubpoenaResponse type for consistency.

The changes effectively implement the separation of requested defender info from assigned defender info, both in the update payload and response handling. This aligns well with the PR objective.

To ensure full type safety and consistency, consider updating the SubpoenaResponse type to reflect these changes:

interface SubpoenaResponse {
  subpoenaComment: string;
  defenderInfo: {
    requestedDefenderChoice: DefenderChoice;
    requestedDefenderName: string | undefined;
  };
}

This will provide better type checking and documentation for the updated response structure.

Also applies to: 168-169

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

95-97: LGTM with suggestions for improvement

The implementation aligns well with the PR objectives to store requested defender information separately. However, consider the following improvements:

  1. Add type annotations for the new properties to maintain consistency with TypeScript best practices:
requestedDefenderChoice: DefenderChoice,
requestedDefenderNationalId: string,
requestedDefenderName: string,
  1. Refactor the conditional check for better readability:
const shouldUpdateDefender = [
  defenderChoice,
  defenderNationalId,
  requestedDefenderChoice,
  requestedDefenderNationalId
].some(Boolean);

if (shouldUpdateDefender) {
  // ... existing update logic
}
  1. Consider adding input validation for the new fields to ensure data integrity and security.

Also applies to: 107-112, 119-121

apps/judicial-system/digital-mailbox-api/src/app/modules/cases/case.service.ts (2)

Line range hint 120-143: Improved handling of defender assignment and choice

The changes in the updateSubpoenaInfo method effectively separate the requested defender information from the actual assignment, aligning with the PR objectives. The error handling and lawyer validation are well-implemented.

Consider adding a comment explaining the purpose of the chosenLawyer variable for better code readability.

    let chosenLawyer = null
+   // Store the chosen lawyer's details if a specific defender is requested
    if (defenderAssignment.defenderChoice === DefenderChoice.CHOOSE) {
      if (!defenderAssignment.defenderNationalId) {
        throw new NotFoundException(
          'Defender national id is required for choice',
        )
      }

228-235: Improved method signature with explicit typing

The renaming of patchSubpoenaInfo to patchDefenseInfo and the updated parameter type enhance code clarity and type safety. The new structure of defenderChoice aligns well with the PR objectives.

Consider using a TypeScript interface or type alias for the defenderChoice object to improve reusability and maintainability.

interface DefenderChoiceInfo {
  requestedDefenderChoice: DefenderChoice;
  requestedDefenderNationalId: string | undefined;
  requestedDefenderName?: string;
}

private async patchDefenseInfo(
  defendantNationalId: string,
  caseId: string,
  defenderChoice: DefenderChoiceInfo
): Promise<InternalDefendantResponse> {
  // ... existing implementation
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 83b076f and 06e8812.

📒 Files selected for processing (14)
  • apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts (1 hunks)
  • apps/judicial-system/backend/migrations/20241011090000-update-defendant.js (1 hunks)
  • apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/subpoena/dto/updateSubpoena.dto.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts (2 hunks)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/case.service.ts (3 hunks)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/internal/internalCase.response.ts (1 hunks)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/internal/internalDefendant.response.ts (1 hunks)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts (3 hunks)
  • apps/judicial-system/web/src/components/FormProvider/case.graphql (1 hunks)
  • apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.strings.ts (1 hunks)
  • apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.tsx (1 hunks)
  • apps/judicial-system/xrd-api/src/app/app.service.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (14)
apps/judicial-system/api/src/app/modules/defendant/models/defendant.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/migrations/20241011090000-update-defendant.js (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/defendant/dto/updateDefendant.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."
apps/judicial-system/backend/src/app/modules/defendant/models/defendant.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/subpoena/dto/updateSubpoena.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."
apps/judicial-system/backend/src/app/modules/subpoena/subpoena.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/digital-mailbox-api/src/app/modules/cases/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."
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/internal/internalCase.response.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/digital-mailbox-api/src/app/modules/cases/models/internal/internalDefendant.response.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/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.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/FormProvider/case.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."
apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.strings.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/routes/Court/Indictments/Advocates/Advocates.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/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."
🪛 Biome
apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.tsx

[error] 65-65: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

🔇 Additional comments (22)
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/internal/internalDefendant.response.ts (2)

7-9: LGTM! The changes align well with the PR objectives.

The addition of requestedDefenderChoice, requestedDefenderNationalId, and requestedDefenderName properties successfully implements the requirement to store requested defender information separately from the actual assigned defender. The use of optional properties and appropriate types is consistent with TypeScript best practices and the existing code structure.


Line range hint 1-11: Verify updates in related components

The changes to InternalDefendantResponse look good. To ensure full implementation of the feature, please verify that related components, services, and GraphQL queries have been updated to utilize these new properties where appropriate.

Run the following script to check for usage of the new properties:

✅ Verification successful

Usage of new properties confirmed

The new properties requestedDefenderChoice, requestedDefenderNationalId, and requestedDefenderName are utilized in related components and services as expected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usage of new properties in related files

# Test: Search for usage of new properties
rg --type typescript -e "requestedDefenderChoice" -e "requestedDefenderNationalId" -e "requestedDefenderName" apps/judicial-system

Length of output: 161


Script:

#!/bin/bash
# Description: Check for usage of new properties in related TypeScript files

# Test: Search for usage of new properties
rg --type ts -e "requestedDefenderChoice" -e "requestedDefenderNationalId" -e "requestedDefenderName" apps/judicial-system

Length of output: 7005

apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/internal/internalCase.response.ts (1)

33-35: LGTM: New properties align with PR objectives and follow best practices.

The addition of requestedDefenderChoice, requestedDefenderNationalId, and requestedDefenderName to the Defendant interface effectively addresses the PR's main objective. These properties allow for separate storage of requested defender information, distinct from the actual assigned defender. The use of optional properties and consistent typing (reusing DefenderChoice and using string for IDs and names) maintains type safety and follows TypeScript best practices.

apps/judicial-system/backend/src/app/modules/subpoena/dto/updateSubpoena.dto.ts (3)

53-56: LGTM: Well-defined requestedDefenderChoice property

The requestedDefenderChoice property is correctly implemented with appropriate decorators for validation and API documentation. It aligns well with the existing defenderChoice property and supports the PR objective of separating requested defender info from the assigned defender.


58-61: LGTM: Well-defined requestedDefenderNationalId property

The requestedDefenderNationalId property is correctly implemented with appropriate decorators for validation and API documentation. It complements the requestedDefenderChoice property and aligns with the PR objective.


63-66: LGTM: Well-defined requestedDefenderName property

The requestedDefenderName property is correctly implemented with appropriate decorators for validation and API documentation. It completes the set of requested defender properties and supports the PR objective.

apps/judicial-system/backend/migrations/20241011090000-update-defendant.js (3)

2-47: LGTM: Well-structured migration with proper use of transactions

The 'up' method is well-structured, using a transaction to ensure atomicity of the migration. The addition of new columns is done correctly using Sequelize methods.


48-72: LGTM: Proper implementation of the 'down' method

The 'down' method is correctly implemented, using a transaction to ensure atomicity and properly removing the columns added in the 'up' method. This ensures that the migration is fully reversible, which is a best practice in database migrations.


1-73: Overall assessment: Well-implemented migration script

This migration script successfully implements the changes required to separate requested defender information from actual assigned defender, aligning well with the PR objectives. The use of transactions, proper structuring of 'up' and 'down' methods, and adherence to Sequelize migration patterns are commendable.

A minor suggestion for improvement has been made regarding the use of Sequelize methods for data population, but overall, this is a solid implementation that should effectively update the database schema as intended.

apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts (4)

97-100: LGTM: Properly defined requestedDefenderChoice property

The requestedDefenderChoice property is correctly implemented as an optional enum of type DefenderChoice. The use of appropriate decorators ensures proper validation and API documentation.


102-105: LGTM: Properly defined requestedDefenderNationalId property

The requestedDefenderNationalId property is correctly implemented as an optional string. The use of appropriate decorators ensures proper validation and API documentation.


107-110: LGTM: Properly defined requestedDefenderName property

The requestedDefenderName property is correctly implemented as an optional string. The use of appropriate decorators ensures proper validation and API documentation.


97-110: Great job: Successfully implemented requested defender properties

The addition of requestedDefenderChoice, requestedDefenderNationalId, and requestedDefenderName properties effectively separates the requested defender information from the actual assigned defender. This change aligns perfectly with the PR objectives and maintains consistency with the existing code structure and best practices.

The implementation:

  1. Enhances the data model's clarity
  2. Maintains type safety and API documentation standards
  3. Follows NextJS and TypeScript best practices
  4. Introduces new functionality without modifying existing code, minimizing the risk of regressions

Great work on implementing this feature!

apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts (2)

78-79: LGTM: New field requestedDefenderChoice added correctly

The addition of requestedDefenderChoice aligns with the PR objective. It's correctly typed as a nullable DefenderChoice and properly decorated for GraphQL schema generation.


84-85: LGTM: New field requestedDefenderName added correctly

The addition of requestedDefenderName is appropriate and aligns with the PR objective. It's correctly typed as a nullable string and properly decorated for GraphQL schema generation.

apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts (3)

141-147: LGTM: Properly implemented requestedDefenderChoice property

The requestedDefenderChoice property is well-implemented:

  • It uses an ENUM type, ensuring type safety and restricting possible values.
  • It allows null values, which is appropriate for an optional field.
  • The @ApiPropertyOptional annotation is correctly used for API documentation.

This implementation aligns well with the PR objective of separating requested defender information from the actual assigned defender.


149-151: LGTM: Well-implemented requestedDefenderNationalId property

The requestedDefenderNationalId property is correctly implemented:

  • It uses a STRING type, which is appropriate for storing national IDs.
  • It allows null values, accommodating cases where the requested defender's national ID might not be available.
  • The @ApiPropertyOptional annotation is correctly used for API documentation.

This implementation supports the PR objective of separately storing requested defender information.


153-155: LGTM: Correctly implemented requestedDefenderName property

The requestedDefenderName property is implemented correctly:

  • It uses a STRING type, which is suitable for storing names.
  • It allows null values, which is appropriate as the requested defender's name might not always be provided.
  • The @ApiPropertyOptional annotation is correctly used for API documentation.

This implementation aligns with the PR objective of separately storing requested defender information.

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

115-116: LGTM! Simplified defender information retrieval.

The changes effectively simplify the defender information retrieval, aligning with the PR objective. The code maintains type safety through the use of the getLawyer method's return type.

apps/judicial-system/web/src/components/FormProvider/case.graphql (1)

25-27: LGTM! New fields align well with PR objectives.

The addition of requestedDefenderChoice, requestedDefenderNationalId, and requestedDefenderName fields is well-implemented and directly addresses the PR's main objective of separating requested defender information from the actual assigned defender. The naming convention is consistent with existing fields, and the placement within the defendants section is logical.

apps/judicial-system/digital-mailbox-api/src/app/modules/cases/case.service.ts (2)

144-146: Appropriate method renaming and parameter passing

The change from patchSubpoenaInfo to patchDefenseInfo accurately reflects the focus on defense information, aligning with the PR objectives. The passing of the defenderChoice object to the new method maintains code clarity and consistency.


Line range hint 236-275: Verify API endpoint compatibility

The patchDefenseInfo method body remains largely unchanged, which is good for maintaining consistency. However, it's important to ensure that the backend API endpoint can handle the new structure of the defenderChoice object.

Please confirm that the backend API endpoint at /api/internal/case/${caseId}/defense/${defendantNationalId} has been updated to handle the new defenderChoice structure with requestedDefenderChoice, requestedDefenderNationalId, and requestedDefenderName.

✅ Verification successful

The previous script encountered an error with the --type typescript flag. Let's retry the search without specifying the file type to ensure we capture the necessary endpoint definitions.


To ensure that the backend API handles the new defenderChoice structure, let's search for the updated properties within the backend codebase.


API Endpoint Compatibility Verified

The backend has been updated to handle the new defenderChoice structure, as confirmed by the presence of requestedDefenderChoice, requestedDefenderNationalId, and requestedDefenderName in the backend codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the API endpoint has been updated in the backend

# Test: Search for the endpoint definition
rg --type typescript "/api/internal/case/.+/defense/.+" apps/judicial-system/backend

Length of output: 119


Script:

#!/bin/bash
# Description: Search for the API endpoint definition in the backend without specifying file type

rg "/api/internal/case/.+/defense/.+" apps/judicial-system/backend

Length of output: 66


Script:

#!/bin/bash
# Description: Search for updated defenderChoice properties in the backend

rg "requestedDefenderChoice|requestedDefenderNationalId|requestedDefenderName" apps/judicial-system/backend

Length of output: 2092

Copy link

codecov bot commented Oct 14, 2024

Codecov Report

Attention: Patch coverage is 40.90909% with 13 lines in your changes missing coverage. Please review.

Project coverage is 36.73%. Comparing base (330e4c1) to head (cd69771).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...rc/app/modules/defendant/models/defendant.model.ts 0.00% 6 Missing ⚠️
...ckend/src/app/modules/subpoena/subpoena.service.ts 0.00% 5 Missing ⚠️
...c/routes/Court/Indictments/Advocates/Advocates.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #16393   +/-   ##
=======================================
  Coverage   36.73%   36.73%           
=======================================
  Files        6809     6809           
  Lines      141088   141109   +21     
  Branches    40225    40233    +8     
=======================================
+ Hits        51826    51835    +9     
- Misses      89262    89274   +12     
Flag Coverage Δ
api 3.37% <ø> (ø)
application-system-api 41.42% <ø> (ø)
application-template-api-modules 27.89% <ø> (+0.01%) ⬆️
application-ui-shell 21.35% <ø> (ø)
judicial-system-api 18.36% <0.00%> (-0.04%) ⬇️
judicial-system-backend 55.19% <64.28%> (+<0.01%) ⬆️
judicial-system-web 27.93% <0.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
...c/app/modules/defendant/dto/updateDefendant.dto.ts 95.83% <100.00%> (+0.59%) ⬆️
...rc/app/modules/defendant/models/defendant.model.ts 85.71% <100.00%> (+1.33%) ⬆️
...src/app/modules/subpoena/dto/updateSubpoena.dto.ts 100.00% <100.00%> (ø)
...s/Court/Indictments/Advocates/Advocates.strings.ts 0.00% <ø> (ø)
...c/routes/Court/Indictments/Advocates/Advocates.tsx 0.00% <0.00%> (ø)
...ckend/src/app/modules/subpoena/subpoena.service.ts 28.39% <0.00%> (-1.48%) ⬇️
...rc/app/modules/defendant/models/defendant.model.ts 0.00% <0.00%> (ø)

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 330e4c1...cd69771. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 14, 2024

Datadog Report

All test runs a19c78b 🔗

8 Total Test Services: 0 Failed, 8 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.04%), 1 increased (+0.02%), 14 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 2.58s 1 no change Link
application-system-api 0 0 0 120 2 3m 35.01s 1 no change Link
application-template-api-modules 0 0 0 123 0 2m 15.74s 1 no change Link
application-ui-shell 0 0 0 74 0 30.71s 1 no change Link
judicial-system-api 0 0 0 57 0 6.88s 1 decreased (-0.04%) Link
judicial-system-backend 0 0 0 21301 0 19m 34.47s 1 increased (+0.02%) Link
judicial-system-web 0 0 0 338 0 1m 10.77s 1 no change Link
judicial-system-xrd-api 0 0 0 6 0 4.98s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • judicial-system-api - jest 19.57% (-0.04%) - Details

Copy link
Member

@gudjong gudjong left a comment

Choose a reason for hiding this comment

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

One suggestion

@unakb unakb added the automerge Merge this PR as soon as all checks pass label Oct 15, 2024
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