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): Data structure for civil claimants #16059

Merged
merged 20 commits into from
Sep 19, 2024

Conversation

oddsson
Copy link
Member

@oddsson oddsson commented Sep 18, 2024

Data structure for civil claimants

Asana

What

This PR implements a data structure for civil claims and civil claimants in the backend. We create a new table CivilClaimant and add a field to the Case table, hasCivilClaims.

Why

We are working on a feature that allows prosecutors to register civil claimants in indictments.

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

    • Introduced functionality for managing civil claimants, including creation, updating, and deletion capabilities.
    • Enhanced the case model to support multiple civil claimants and indicate the presence of civil claims.
    • Added GraphQL input types for streamlined civil claimant creation.
    • Expanded API functionality to support civil claimant operations.
  • Bug Fixes

    • Improved error handling for civil claimant operations, ensuring robust logging and feedback.
  • Documentation

    • Updated API documentation to reflect new civil claimant features and data structures.
  • Chores

    • Added new database migrations for civil claimant management.

@oddsson oddsson requested a review from a team as a code owner September 18, 2024 14:02
Copy link
Contributor

coderabbitai bot commented Sep 18, 2024

Walkthrough

The pull request introduces enhancements to the judicial system's backend, focusing on the management of civil claimants. It implements the CivilClaimantService class, which provides methods for creating, updating, and deleting civil claimant records. Additionally, it updates the BackendService and Case model to accommodate these changes, ensuring effective association and management of civil claimants within the system.

Changes

Files Change Summary
apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.service.ts Added CivilClaimantService class with methods: create, update, and delete for managing civil claimants.
apps/judicial-system/api/src/app/modules/backend/backend.service.ts Added methods: createCivilClaimant, updateCivilClaimant, and deleteCivilClaimant to manage civil claimants in the backend service.
apps/judicial-system/api/src/app/modules/case/models/case.model.ts Added properties: civilClaimants (array of CivilClaimant) and hasCivilClaims (boolean) to the Case class.
apps/judicial-system/api/src/app/modules/defendant/dto/createCivilClaimant.input.ts Introduced CreateCivilClaimantInput GraphQL input type for creating civil claimants, including a mandatory caseId field.
apps/judicial-system/api/src/app/modules/defendant/index.ts Added exports for CivilClaimant and DeleteCivilClaimantResponse entities.
apps/judicial-system/api/src/app/modules/defendant/models/civilClaimant.model.ts Introduced CivilClaimant GraphQL object type with various fields for claimant information.
apps/judicial-system/backend/migrations/20240918134825-create-civil-claimant.js Created a new database table civil_claimant to store civil claimant information, including relevant fields and timestamps.
apps/judicial-system/backend/src/app/modules/case/case.service.ts Updated to include CivilClaimant in data retrieval for cases, allowing association and ordering of civil claimants with cases.

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • gudjong

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

Outside diff range and nitpick comments (19)
apps/judicial-system/backend/migrations/20240918134926-update-case.js (1)

8-14: Consider setting a default value for the new column

Currently, has_civil_claims allows null values. If appropriate, consider setting allowNull: false and providing a defaultValue to ensure data integrity.

Apply this diff to set a default value:

 queryInterface.addColumn(
   'case',
   'has_civil_claims',
   {
     type: Sequelize.BOOLEAN,
-    allowNull: true,
+    allowNull: false,
+    defaultValue: false,
   },
   { transaction: t },
 )
apps/judicial-system/backend/src/app/modules/defendant/dto/createCivilClaimant.dto.ts (4)

44-45: Add email validation for spokespersonEmail field

Consider adding the @IsEmail() decorator to validate the email format of the spokespersonEmail field.

Apply this diff to implement the email validation:

 @IsOptional()
+@IsEmail()
 @IsString()
 @ApiPropertyOptional({ type: String })
 readonly spokespersonEmail?: string

46-49: Add phone number validation for spokespersonPhoneNumber field

Consider adding the @IsPhoneNumber() decorator to validate the phone number format of the spokespersonPhoneNumber field.

Apply this diff to implement the phone number validation:

 @IsOptional()
+@IsPhoneNumber()
 @IsString()
 @ApiPropertyOptional({ type: String })
 readonly spokespersonPhoneNumber?: string

16-19: Add validation for nationalId field

Consider adding validation to ensure the nationalId field conforms to the expected format. You can use the @Matches() decorator with a regular expression based on the national ID specifications.

Example:

 @IsOptional()
+@Matches(/^\d{10}$/) // Assuming national ID is 10 digits
 @IsString()
 @ApiPropertyOptional({ type: String })
 readonly nationalId?: string

34-35: Add validation for spokespersonNationalId field

Similarly, consider adding validation for the spokespersonNationalId field to ensure it matches the expected national ID format.

Example:

 @IsOptional()
+@Matches(/^\d{10}$/) // Assuming national ID is 10 digits
 @IsString()
 @ApiPropertyOptional({ type: String })
 readonly spokespersonNationalId?: string
apps/judicial-system/backend/src/app/modules/defendant/dto/updateCivilClaimant.dto.ts (4)

44-45: Add email validation for spokespersonEmail field

Consider adding the @IsEmail() decorator to validate the email format of the spokespersonEmail field.

Apply this diff to implement the email validation:

 @IsOptional()
+@IsEmail()
 @IsString()
 @ApiPropertyOptional({ type: String })
 readonly spokespersonEmail?: string

46-49: Add phone number validation for spokespersonPhoneNumber field

Consider adding the @IsPhoneNumber() decorator to validate the phone number format of the spokespersonPhoneNumber field.

Apply this diff to implement the phone number validation:

 @IsOptional()
+@IsPhoneNumber()
 @IsString()
 @ApiPropertyOptional({ type: String })
 readonly spokespersonPhoneNumber?: string

16-19: Add validation for nationalId field

Consider adding validation to ensure the nationalId field conforms to the expected format.

Example:

 @IsOptional()
+@Matches(/^\d{10}$/) // Assuming national ID is 10 digits
 @IsString()
 @ApiPropertyOptional({ type: String })
 readonly nationalId?: string

34-35: Add validation for spokespersonNationalId field

Consider adding validation for the spokespersonNationalId field to ensure it matches the expected national ID format.

Example:

 @IsOptional()
+@Matches(/^\d{10}$/) // Assuming national ID is 10 digits
 @IsString()
 @ApiPropertyOptional({ type: String })
 readonly spokespersonNationalId?: string
apps/judicial-system/api/src/app/modules/defendant/dto/createCivilClaimant.input.ts (4)

49-50: Add email validation for spokespersonEmail field

Consider adding the @IsEmail() decorator to validate the email format of the spokespersonEmail field.

Apply this diff:

 @Allow()
 @IsOptional()
+@IsEmail()
 @Field(() => String, { nullable: true })
 readonly spokespersonEmail?: string

51-54: Add phone number validation for spokespersonPhoneNumber field

Consider adding the @IsPhoneNumber() decorator to validate the phone number format of the spokespersonPhoneNumber field.

Apply this diff:

 @Allow()
 @IsOptional()
+@IsPhoneNumber()
 @Field(() => String, { nullable: true })
 readonly spokespersonPhoneNumber?: string

24-25: Add validation for nationalId field

Consider adding validation to ensure the nationalId field matches the expected format.

Example:

 @Allow()
 @IsOptional()
+@Matches(/^\d{10}$/) // Assuming national ID is 10 digits
 @Field(() => String, { nullable: true })
 readonly nationalId?: string

39-40: Add validation for spokespersonNationalId field

Consider adding validation for the spokespersonNationalId field.

Example:

 @Allow()
 @IsOptional()
+@Matches(/^\d{10}$/) // Assuming national ID is 10 digits
 @Field(() => String, { nullable: true })
 readonly spokespersonNationalId?: string
apps/judicial-system/api/src/app/modules/defendant/dto/updateCivilClaimant.input.ts (4)

53-54: Add email validation for spokespersonEmail field

Consider adding the @IsEmail() decorator to validate the email format of the spokespersonEmail field.

Apply this diff:

 @Allow()
 @IsOptional()
+@IsEmail()
 @Field(() => String, { nullable: true })
 readonly spokespersonEmail?: string

55-58: Add phone number validation for spokespersonPhoneNumber field

Consider adding the @IsPhoneNumber() decorator to validate the phone number format of the spokespersonPhoneNumber field.

Apply this diff:

 @Allow()
 @IsOptional()
+@IsPhoneNumber()
 @Field(() => String, { nullable: true })
 readonly spokespersonPhoneNumber?: string

28-29: Add validation for nationalId field

Consider adding validation to ensure the nationalId field matches the expected format.

Example:

 @Allow()
 @IsOptional()
+@Matches(/^\d{10}$/) // Assuming national ID is 10 digits
 @Field(() => String, { nullable: true })
 readonly nationalId?: string

43-44: Add validation for spokespersonNationalId field

Consider adding validation for the spokespersonNationalId field.

Example:

 @Allow()
 @IsOptional()
+@Matches(/^\d{10}$/) // Assuming national ID is 10 digits
 @Field(() => String, { nullable: true })
 readonly spokespersonNationalId?: string
apps/judicial-system/backend/src/app/modules/case/models/case.model.ts (1)

1080-1082: Uncomment the documentation for 'civilClaimants' property

The documentation comment for the civilClaimants property is currently commented out. Please uncomment it to ensure proper documentation.

Apply this diff to fix the issue:

-  // /**********
-  //  * The case's civil claimants
-  //  **********/
+  /**********
+   * The case's civil claimants
+   **********/
apps/judicial-system/backend/src/app/modules/case/case.service.ts (1)

276-276: Consider performance impact of including 'civilClaimants'

Including civilClaimants in the include array will eager load all associated civil claimants whenever a case is queried. If the number of civil claimants per case is large or if they are not always needed, this could negatively affect performance. Consider implementing lazy loading or conditional includes to optimize database queries.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2dd6e46 and c8d32b4.

Files selected for processing (26)
  • apps/judicial-system/api/src/app/modules/backend/backend.service.ts (2 hunks)
  • apps/judicial-system/api/src/app/modules/case/dto/updateCase.input.ts (1 hunks)
  • apps/judicial-system/api/src/app/modules/case/models/case.model.ts (2 hunks)
  • apps/judicial-system/api/src/app/modules/defendant/civilClaimant.resolver.ts (1 hunks)
  • apps/judicial-system/api/src/app/modules/defendant/defendant.module.ts (1 hunks)
  • apps/judicial-system/api/src/app/modules/defendant/dto/createCivilClaimant.input.ts (1 hunks)
  • apps/judicial-system/api/src/app/modules/defendant/dto/deleteCivilClaimant.input.ts (1 hunks)
  • apps/judicial-system/api/src/app/modules/defendant/dto/updateCivilClaimant.input.ts (1 hunks)
  • apps/judicial-system/api/src/app/modules/defendant/models/civilClaimant.model.ts (1 hunks)
  • apps/judicial-system/api/src/app/modules/defendant/models/deleteCivilClaimant.response.ts (1 hunks)
  • apps/judicial-system/backend/migrations/20240918134825-create-civil-claimant.js (1 hunks)
  • apps/judicial-system/backend/migrations/20240918134926-update-case.js (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/case.service.ts (2 hunks)
  • apps/judicial-system/backend/src/app/modules/case/dto/updateCase.dto.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/guards/rolesRules.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/models/case.model.ts (3 hunks)
  • apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.controller.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.service.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/defendant/defendant.module.ts (2 hunks)
  • apps/judicial-system/backend/src/app/modules/defendant/dto/createCivilClaimant.dto.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/defendant/dto/updateCivilClaimant.dto.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/defendant/models/civilClaimant.model.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/defendant/models/deleteCivilClaimant.response.ts (1 hunks)
  • apps/judicial-system/web/src/components/FormProvider/case.graphql (1 hunks)
  • apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx (2 hunks)
  • libs/judicial-system/audit-trail/src/lib/auditTrail.service.ts (1 hunks)
Additional context used
Path-based instructions (26)
apps/judicial-system/backend/src/app/modules/defendant/models/deleteCivilClaimant.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/api/src/app/modules/defendant/models/deleteCivilClaimant.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/api/src/app/modules/defendant/defendant.module.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/api/src/app/modules/defendant/dto/deleteCivilClaimant.input.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/20240918134926-update-case.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/defendant.module.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/api/src/app/modules/defendant/models/civilClaimant.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/defendant/dto/createCivilClaimant.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/dto/updateCivilClaimant.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/api/src/app/modules/defendant/dto/createCivilClaimant.input.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/api/src/app/modules/defendant/dto/updateCivilClaimant.input.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/20240918134825-create-civil-claimant.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/civilClaimant.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/defendant/models/civilClaimant.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/api/src/app/modules/defendant/civilClaimant.resolver.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/civilClaimant.controller.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."
libs/judicial-system/audit-trail/src/lib/auditTrail.service.ts (1)

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

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.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/backend/src/app/modules/case/guards/rolesRules.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/api/src/app/modules/case/dto/updateCase.input.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/api/src/app/modules/backend/backend.service.ts (1)

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

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

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
Biome
apps/judicial-system/backend/migrations/20240918134926-update-case.js

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

apps/judicial-system/backend/migrations/20240918134825-create-civil-claimant.js

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

Additional comments not posted (18)
apps/judicial-system/backend/src/app/modules/defendant/models/deleteCivilClaimant.response.ts (1)

1-6: LGTM!

The new response class correctly defines the structure for the deletion operation.

apps/judicial-system/api/src/app/modules/defendant/models/deleteCivilClaimant.response.ts (1)

1-7: LGTM!

The GraphQL response type is correctly defined and adheres to best practices.

apps/judicial-system/api/src/app/modules/defendant/defendant.module.ts (1)

3-3: LGTM!

The CivilClaimantResolver has been correctly added to the module imports and providers.

Also applies to: 7-7

apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx (2)

23-23: Import statement is appropriate

The import of IndictmentDecision is necessary and used correctly within the component.


41-41: Commented-out code is acceptable due to planned future use

The line const caseHasBeenReceivedByCourt = workingCase.state === CaseState.RECEIVED has been commented out, accompanied by an explanatory comment indicating future use. This practice is acceptable in this context.

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

56-56: Appropriate addition of 'hasCivilClaims' to prosecutorFields

The field 'hasCivilClaims' has been correctly added to the prosecutorFields array, allowing prosecutors to update this field in UpdateCaseDto.

apps/judicial-system/api/src/app/modules/case/dto/updateCase.input.ts (1)

515-518: Correct addition of 'hasCivilClaims' field

The optional boolean field hasCivilClaims has been appropriately added to the UpdateCaseInput class with correct validation decorators and GraphQL field settings.

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

522-525: Correctly added 'hasCivilClaims' property with validations

The optional boolean property hasCivilClaims has been appropriately added to the UpdateCaseDto class with proper validation and API documentation annotations.

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

458-459: Added 'civilClaimants' field to the Case model

The civilClaimants field has been correctly added to the Case model, enabling association with multiple CivilClaimant instances.


464-465: Included 'hasCivilClaims' field in the Case model

The optional boolean field hasCivilClaims has been suitably added to the Case model to indicate the presence of civil claims.

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

41-41: Import 'CivilClaimant' model

The import statement for the CivilClaimant model is correctly added.


1073-1078: Addition of 'hasCivilClaims' property

The new optional boolean property hasCivilClaims is appropriately added with correct Sequelize and Swagger annotations.


1083-1085: Define 'civilClaimants' association correctly

The @HasMany association with CivilClaimant is correctly defined, establishing the relationship between cases and their civil claimants.

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

59-59: Import 'CivilClaimant' model

The import statement for the CivilClaimant model is correctly added.

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

1-113: Model definition is well-structured

The CivilClaimant model is correctly defined with appropriate data types, foreign key relationships, and optional fields. The use of sequelize-typescript decorators ensures that the model aligns with the database schema. Swagger decorators are properly included for API documentation purposes.

apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.controller.ts (1)

30-33: Controller is properly secured with guards and roles

The CivilClaimantController is correctly set up with JWT authentication, case existence, and write guards, as well as role-based access control using RolesRules. This ensures that only authorized users can perform create, update, and delete operations on civil claimants.

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

311-326: GraphQL query enhancements are appropriate

The inclusion of civilClaimants and hasCivilClaims fields in the Case query is appropriate and aligns with the backend changes. The fields are correctly structured to retrieve necessary information about civil claimants, enabling the frontend to display this data as needed.

libs/judicial-system/audit-trail/src/lib/auditTrail.service.ts (1)

60-62: Audit actions extended successfully

Adding CREATE_CIVIL_CLAIMANT, UPDATE_CIVIL_CLAIMANT, and DELETE_CIVIL_CLAIMANT to the AuditedAction enum appropriately extends the audit trail to include civil claimant operations. This enhances monitoring and compliance within the system.

Copy link

codecov bot commented Sep 18, 2024

Codecov Report

Attention: Patch coverage is 11.68831% with 204 lines in your changes missing coverage. Please review.

Project coverage is 36.66%. Comparing base (5d3444a) to head (fe8f59a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...rc/app/modules/defendant/civilClaimant.resolver.ts 0.00% 40 Missing ⚠️
...pp/modules/defendant/models/civilClaimant.model.ts 0.00% 30 Missing ⚠️
.../app/modules/defendant/civilClaimant.controller.ts 0.00% 29 Missing ⚠️
...modules/defendant/dto/updateCivilClaimant.input.ts 0.00% 27 Missing ⚠️
...src/app/modules/defendant/civilClaimant.service.ts 0.00% 23 Missing ⚠️
...p/modules/defendant/dto/updateCivilClaimant.dto.ts 0.00% 13 Missing ⚠️
...modules/defendant/dto/deleteCivilClaimant.input.ts 0.00% 7 Missing ⚠️
...tem/api/src/app/modules/backend/backend.service.ts 0.00% 6 Missing ⚠️
...stem/api/src/app/modules/case/models/case.model.ts 0.00% 5 Missing ⚠️
...modules/defendant/dto/createCivilClaimant.input.ts 0.00% 5 Missing ⚠️
... and 8 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16059      +/-   ##
==========================================
- Coverage   36.70%   36.66%   -0.05%     
==========================================
  Files        6735     6746      +11     
  Lines      138459   138676     +217     
  Branches    39377    39455      +78     
==========================================
+ Hits        50827    50843      +16     
- Misses      87632    87833     +201     
Flag Coverage Δ
api 3.39% <ø> (ø)
api-domains-auth-admin 49.89% <ø> (ø)
api-domains-communications 40.00% <ø> (ø)
application-system-api 41.52% <ø> (ø)
application-template-api-modules 23.47% <ø> (+0.01%) ⬆️
cms 0.43% <ø> (ø)
cms-translations 39.13% <ø> (ø)
content-search-toolkit 8.50% <ø> (ø)
judicial-system-api 18.61% <0.00%> (-0.79%) ⬇️
judicial-system-audit-trail 68.78% <100.00%> (+0.24%) ⬆️
judicial-system-backend 54.72% <24.24%> (-0.17%) ⬇️
judicial-system-web 28.71% <ø> (+<0.01%) ⬆️
services-user-notification 47.17% <ø> (ø)

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

Files with missing lines Coverage Δ
...ystem/backend/src/app/modules/case/case.service.ts 90.64% <100.00%> (ø)
...backend/src/app/modules/case/dto/updateCase.dto.ts 86.72% <100.00%> (+0.11%) ⬆️
.../backend/src/app/modules/case/guards/rolesRules.ts 45.76% <ø> (ø)
...-system/backend/src/app/modules/defendant/index.ts 100.00% <100.00%> (ø)
...src/routes/Court/Indictments/Overview/Overview.tsx 0.00% <ø> (ø)
...l-system/audit-trail/src/lib/auditTrail.service.ts 96.80% <100.00%> (+0.10%) ⬆️
.../api/src/app/modules/defendant/defendant.module.ts 0.00% <0.00%> (ø)
...m/api/src/app/modules/case/dto/updateCase.input.ts 0.00% <0.00%> (ø)
...cial-system/api/src/app/modules/defendant/index.ts 0.00% <0.00%> (ø)
.../backend/src/app/modules/case/models/case.model.ts 72.72% <60.00%> (-0.47%) ⬇️
... and 14 more

... 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 5d3444a...fe8f59a. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Sep 18, 2024

Datadog Report

All test runs 15c931b 🔗

14 Total Test Services: 0 Failed, 13 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.87%), 2 increased, 30 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 2.89s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 12.44s 1 no change Link
api-domains-communications 0 0 0 5 0 32.8s 1 no change Link
api-domains-license-service 0 0 0 0 0 528.14ms 1 no change Link
application-system-api 0 0 0 111 2 2m 52.27s 1 no change Link
application-template-api-modules 0 0 0 109 0 1m 52.74s 1 no change Link
cms-translations 0 0 0 3 0 28.69s 1 no change Link
content-search-toolkit 0 0 0 4 0 11.45s 1 no change Link
judicial-system-api 0 0 0 57 0 6.76s 1 decreased (-0.87%) Link
judicial-system-audit-trail 0 0 0 7 0 9.86s 1 increased (+0.26%) Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • judicial-system-api - jest 19.75% (-0.87%) - 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: 4

Outside diff range and nitpick comments (1)
apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.service.ts (1)

56-61: Consider Using Transactions for Update and Delete Operations

Database operations that modify data should be executed within transactions to ensure atomicity and consistency, especially when multiple related operations are involved.

Consider wrapping the update and delete methods in transactions to prevent partial changes in case of errors.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c8d32b4 and c306255.

Files selected for processing (1)
  • apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.service.ts (1 hunks)
Additional context used
Path-based instructions (1)
apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.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."

@island-is island-is deleted a comment from coderabbitai bot Sep 18, 2024
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.

This looks good. I have some suggestion regarding the import patterns.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c306255 and 1e8c24a.

Files selected for processing (11)
  • apps/judicial-system/api/src/app/modules/backend/backend.service.ts (2 hunks)
  • apps/judicial-system/api/src/app/modules/case/models/case.model.ts (2 hunks)
  • apps/judicial-system/api/src/app/modules/defendant/dto/createCivilClaimant.input.ts (1 hunks)
  • apps/judicial-system/api/src/app/modules/defendant/index.ts (1 hunks)
  • apps/judicial-system/api/src/app/modules/defendant/models/civilClaimant.model.ts (1 hunks)
  • apps/judicial-system/backend/migrations/20240918134825-create-civil-claimant.js (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/case.service.ts (4 hunks)
  • apps/judicial-system/backend/src/app/modules/case/models/case.model.ts (3 hunks)
  • apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.controller.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.service.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/defendant/index.ts (1 hunks)
Files skipped from review as they are similar to previous changes (6)
  • apps/judicial-system/api/src/app/modules/backend/backend.service.ts
  • apps/judicial-system/api/src/app/modules/case/models/case.model.ts
  • apps/judicial-system/api/src/app/modules/defendant/dto/createCivilClaimant.input.ts
  • apps/judicial-system/api/src/app/modules/defendant/models/civilClaimant.model.ts
  • apps/judicial-system/backend/src/app/modules/case/models/case.model.ts
  • apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.service.ts
Additional context used
Path-based instructions (5)
apps/judicial-system/api/src/app/modules/defendant/index.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/20240918134825-create-civil-claimant.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/case/case.service.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.controller.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/index.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/backend/migrations/20240918134825-create-civil-claimant.js

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

Additional comments not posted (14)
apps/judicial-system/backend/src/app/modules/defendant/index.ts (1)

3-3: LGTM!

The new export of the CivilClaimant entity from the ./models/civilClaimant.model file is a valid addition to the index.ts file. It follows the existing export pattern and enhances the module's functionality by making the CivilClaimant model accessible for use in other parts of the application. This change is unlikely to have any negative impact on the existing functionality related to defendants.

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

3-3: LGTM!

The export of the CivilClaimant entity aligns with the PR objective of introducing a new data structure for managing civil claimants. Making it accessible from the module's index file is a good practice.


4-4: Looks good!

The export of the DeleteCivilClaimantResponse entity suggests that the module supports deleting civil claimants, which aligns with the overall goal of managing civil claimants. I assume this entity represents the response structure for a delete operation on civil claimants.

apps/judicial-system/backend/migrations/20240918134825-create-civil-claimant.js (3)

4-77: LGTM!

The up function correctly creates the civil_claimant table with the necessary fields to store information about civil claimants. The use of a transaction ensures the atomicity of the table creation.


79-83: LGTM!

The down function correctly drops the civil_claimant table using a transaction to ensure atomicity.


3-84: The migration file follows best practices and is well-structured.

The file exports an object with up and down functions for creating and dropping the civil_claimant table. The use of transactions in these functions ensures data integrity during the migration process.

The file is located in the appropriate directory for backend migrations and follows the standard structure for defining database migrations.

While the migration file itself does not directly relate to NextJS-specific concerns like API routes or static generation, it adheres to general best practices for structuring and implementing database migrations.

apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.controller.ts (4)

1-32: LGTM!

The import statements and the controller definition are correctly implemented. The use of @UseGuards, @Controller, and @ApiTags decorators is appropriate.


33-52: LGTM!

The constructor and the create method are correctly implemented. The use of decorators, parameters, and the service call is appropriate.


54-74: LGTM!

The update method is correctly implemented. The use of decorators, parameters, and the service call is appropriate.


76-96: LGTM!

The delete method is correctly implemented. The use of decorators, parameters, the service call, and the response object is appropriate.

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

58-58: LGTM!

The import statement for the CivilClaimant model is syntactically correct and aligns with the PR objectives.


275-275: Looks good!

Including the CivilClaimant model in the include array is necessary to eagerly load the associated civil claimant records when querying cases. The syntax and alias are correct.


343-343: Ordering looks good!

Adding the CivilClaimant model to the order array with the created timestamp in ascending order is a sensible default for ordering the related civil claimant records. The syntax is correct and consistent with the ordering of other entities.


398-398: Ordering for case listing looks good!

Adding the CivilClaimant model to the listOrder array with the created timestamp in ascending order maintains consistency with the ordering specified in the order array. The syntax is correct, and the default ordering is reasonable for listing cases.

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