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): Add subpoenaType to Defendant table #15198

Merged
merged 5 commits into from
Jun 12, 2024

Conversation

oddsson
Copy link
Member

@oddsson oddsson commented Jun 11, 2024

Add subpoena type to case table

Asana

What

Add a new field, subpoenaType to DB.

Why

This is a part of the new indictment cases flow we are creating.

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 subpoenaType field to various components and models to support different types of subpoenas (e.g., 'ABSENCE' and 'ARREST').
  • Bug Fixes

    • Corrected typos in import statements for mutation hooks related to defendants.

Copy link
Contributor

coderabbitai bot commented Jun 11, 2024

Walkthrough

The changes introduce a new SubpoenaType enum to the judicial system application, adding it as an optional field to the Defendant class and related DTOs. This involves updates to GraphQL queries and mutations, Sequelize migration scripts, and type definitions. Additionally, minor corrections were made to import statements in some files.

Changes

Files/Paths Change Summary
apps/judicial-system/api/src/app/modules/defendant/dto/updateDefendant.input.ts Added subpoenaType field of type SubpoenaType to UpdateDefendantInput class.
apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts Added SubpoenaType enum and subpoenaType field to Defendant class.
apps/judicial-system/backend/migrations/20240611213639-update-defendant.js Added migration script to include subpoena_type column in defendant table.
apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts Added subpoenaType field with validation decorators to UpdateDefendantDto class.
apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts Added subpoenaType field with annotations to Defendant model.
apps/judicial-system/web/src/components/FormProvider/case.graphql Added subpoenaType field to Case query.
apps/judicial-system/web/src/utils/hooks/useCase/updateCase.graphql Added subpoenaType field to UpdateCase mutation.
libs/judicial-system/types/src/index.ts Exported SubpoenaType enum from defendant module.
libs/judicial-system/types/src/lib/defendant.ts Added SubpoenaType enum with values 'ABSENCE' and 'ARREST'.
apps/judicial-system/web/src/utils/hooks/useDefendants/index.ts Corrected typos in import statements for mutation hooks related to defendants.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant WebApp
    participant Backend
    participant Database

    Client->>WebApp: Update Defendant (subpoenaType)
    WebApp->>Backend: Send UpdateDefendantDto (subpoenaType)
    Backend->>Database: Update defendant table with subpoena_type
    Database->>Backend: Acknowledge update
    Backend->>WebApp: Confirm update
    WebApp->>Client: Display updated defendant info
Loading

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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 Jun 11, 2024

Codecov Report

Attention: Patch coverage is 54.54545% with 5 lines in your changes missing coverage. Please review.

Project coverage is 37.02%. Comparing base (4862a0a) to head (38f33aa).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #15198   +/-   ##
=======================================
  Coverage   37.02%   37.02%           
=======================================
  Files        6423     6423           
  Lines      131043   131053   +10     
  Branches    37524    37529    +5     
=======================================
+ Hits        48513    48518    +5     
- Misses      82530    82535    +5     
Flag Coverage Δ
judicial-system-api 18.14% <44.44%> (+0.05%) ⬆️
judicial-system-backend 55.96% <100.00%> (+0.01%) ⬆️
judicial-system-formatters 81.36% <100.00%> (+0.07%) ⬆️
judicial-system-message 65.72% <ø> (ø)
judicial-system-types 49.06% <0.00%> (-0.28%) ⬇️
judicial-system-web 28.22% <ø> (ø)

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

Files Coverage Δ
...c/app/modules/defendant/dto/updateDefendant.dto.ts 100.00% <100.00%> (ø)
...rc/app/modules/defendant/models/defendant.model.ts 89.65% <100.00%> (+0.36%) ⬆️
...-system/web/src/utils/hooks/useDefendants/index.ts 2.17% <ø> (ø)
libs/judicial-system/types/src/index.ts 100.00% <100.00%> (ø)
libs/judicial-system/types/src/lib/defendant.ts 100.00% <100.00%> (ø)
...app/modules/defendant/dto/updateDefendant.input.ts 0.00% <0.00%> (ø)
...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 4862a0a...38f33aa. Read the comment docs.

@oddsson oddsson changed the title Add subpoenaType to Defendant table feat(j-s): Add subpoenaType to Defendant table Jun 11, 2024
@oddsson oddsson marked this pull request as ready for review June 11, 2024 22:18
@oddsson oddsson requested a review from a team as a code owner June 11, 2024 22:18
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

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

Line range hint 1-1: Please run the autofix to sort the imports as suggested by the linting tool.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4862a0a and 62241b5.

Files selected for processing (9)
  • apps/judicial-system/api/src/app/modules/defendant/dto/updateDefendant.input.ts (2 hunks)
  • apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts (2 hunks)
  • apps/judicial-system/backend/migrations/20240611213639-update-defendant.js (1 hunks)
  • apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts (2 hunks)
  • apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts (2 hunks)
  • apps/judicial-system/web/src/components/FormProvider/case.graphql (1 hunks)
  • apps/judicial-system/web/src/utils/hooks/useCase/updateCase.graphql (1 hunks)
  • libs/judicial-system/types/src/index.ts (1 hunks)
  • libs/judicial-system/types/src/lib/defendant.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • libs/judicial-system/types/src/index.ts
Additional context used
Path-based instructions (8)
libs/judicial-system/types/src/lib/defendant.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/backend/migrations/20240611213639-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/api/src/app/modules/defendant/dto/updateDefendant.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/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/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/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/web/src/utils/hooks/useCase/updateCase.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/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."
GitHub Check: linting (judicial-system-backend)
apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts

[failure] 1-1:
Run autofix to sort these imports!

Additional comments not posted (9)
libs/judicial-system/types/src/lib/defendant.ts (1)

14-17: The addition of the SubpoenaType enum is well-defined and aligns with the PR objectives.

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

93-96: The addition of the optional subpoenaType field is correctly implemented and aligns with the PR objectives.

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

89-92: The addition of the optional subpoenaType field is correctly implemented and aligns with the PR objectives.

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

8-8: The import and registration of SubpoenaType are correctly implemented.

Also applies to: 15-15


79-80: The addition of the subpoenaType field to the Defendant class is correctly implemented with appropriate GraphQL decorators.

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

19-19: The import of SubpoenaType is correctly implemented.


134-140: The addition of the subpoenaType field to the Defendant model is correctly implemented with appropriate Sequelize decorators and dynamic enum values.

apps/judicial-system/web/src/utils/hooks/useCase/updateCase.graphql (1)

25-25: The addition of the subpoenaType field in the updateCase mutation is correctly implemented.

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

28-28: The addition of the subpoenaType field in the case query is correctly implemented.

@datadog-island-is
Copy link

datadog-island-is bot commented Jun 11, 2024

Datadog Report

All test runs e9bcaeb 🔗

8 Total Test Services: 0 Failed, 8 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.32%), 5 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 54 0 10.24s 1 increased (+0.05%) Link
judicial-system-backend 0 0 0 20375 0 18m 51.38s 1 increased (+0.02%) Link
judicial-system-formatters 0 0 0 36 0 10.41s 1 increased (+0.04%) Link
judicial-system-message 0 0 0 29 0 14.93s 1 no change Link
judicial-system-message-handler 0 0 0 3 0 8.22s 1 increased (+0.08%) Link
judicial-system-types 0 0 0 19 0 13.4s 1 decreased (-0.32%) Link
judicial-system-web 0 0 0 312 0 1m 23.76s 1 no change Link
judicial-system-xrd-api 0 0 0 6 0 15.57s 1 increased (+0.07%) Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • judicial-system-types - jest 53.25% (-0.32%) - Details

Copy link
Member

@unakb unakb left a comment

Choose a reason for hiding this comment

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

Nice, looks good! There's just one linting error that Git caught in the update defendant dto.

@oddsson oddsson added the automerge Merge this PR as soon as all checks pass label Jun 12, 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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 62241b5 and c317aa4.

Files selected for processing (1)
  • apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts

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/web/src/utils/hooks/useDefendants/index.ts (2)

Line range hint 55-57: Consider simplifying the control flow by removing the unnecessary else clause.

-        } else {
-          return false
-        }

This change makes the code cleaner and reduces unnecessary nesting.


Line range hint 76-78: Similar to the previous comment, the else clause here is redundant and can be omitted for cleaner code.

-        } else {
-          return false
-        }

Removing this will streamline the function and improve readability.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c317aa4 and 38f33aa.

Files selected for processing (1)
  • apps/judicial-system/web/src/utils/hooks/useDefendants/index.ts (1 hunks)
Additional context used
Path-based instructions (1)
apps/judicial-system/web/src/utils/hooks/useDefendants/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/web/src/utils/hooks/useDefendants/index.ts

[error] 55-57: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 76-78: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.

Additional comments not posted (2)
apps/judicial-system/web/src/utils/hooks/useDefendants/index.ts (2)

13-15: Corrected typos in import statements enhance maintainability and prevent potential runtime errors.


Line range hint 1-100: The implementation adheres to NextJS best practices, including efficient state management and optimal use of TypeScript for type safety.

@kodiakhq kodiakhq bot merged commit c03383e into main Jun 12, 2024
37 checks passed
@kodiakhq kodiakhq bot deleted the j-s/subpoena-type-to-db-pt2 branch June 12, 2024 10:34
sigruntg pushed a commit that referenced this pull request Jun 12, 2024
* Add subpoenaType to Defendant table

* Fix lint

* Fix build

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
lodmfjord pushed a commit that referenced this pull request Jun 14, 2024
* Add subpoenaType to Defendant table

* Fix lint

* Fix build

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants