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): Return subpoena info from digital mailbox API #15306

Merged
merged 8 commits into from
Jun 25, 2024

Conversation

unakb
Copy link
Member

@unakb unakb commented Jun 21, 2024

Sækja fyrirkall

What

Return subpoena data from the digital mailbox API

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Introduced new class SubpoenaData to enhance the data structure of subpoenas.
    • Added a data property to SubpoenaResponse for better case detail management.
    • Implemented multilingual support for case-related terms in English and Icelandic.
  • Enhancements

    • Improved date formatting and translation functionalities for case details.

Copy link
Contributor

coderabbitai bot commented Jun 21, 2024

Walkthrough

The changes enhance the subpoena.response.ts file within the digital-mailbox-api module of the judicial system application by including new classes and properties to better manage and format subpoena data based on case details. Additionally, a new file translations.strings.ts introduces language-specific strings for case-related terms and functionality to retrieve translations based on the selected language.

Changes

Files/Paths Change Summaries
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts Added necessary imports, SubpoenaData class, data property in SubpoenaResponse class, and updated logic.
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/utils/translations.strings.ts Introduced translations for English and Icelandic, added types for languages and translations, and the getTranslations function.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant DigitalMailboxAPI
    participant SubpoenaResponse
    participant Translations

    Client->>DigitalMailboxAPI: Request case details
    DigitalMailboxAPI->>SubpoenaResponse: Initialize with case details
    SubpoenaResponse-->>SubpoenaResponse: Populate `data` property
    SubpoenaResponse->>Translations: Request translations based on language
    Translations-->>SubpoenaResponse: Return translated strings
    SubpoenaResponse-->>DigitalMailboxAPI: Return formatted subpoena response
    DigitalMailboxAPI->>Client: Send subpoena response
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.

@datadog-island-is
Copy link

datadog-island-is bot commented Jun 21, 2024

Datadog Report

Branch report: j-s/subpoena-info
Commit report: df7639b
Test service: judicial-system-backend

✅ 0 Failed, 20416 Passed, 0 Skipped, 15m 28.47s Total Time
➡️ Test Sessions change in coverage: 1 no change

Copy link

codecov bot commented Jun 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.13%. Comparing base (0f98314) to head (a0757ba).
Report is 1 commits behind head on main.

Current head a0757ba differs from pull request most recent head 681a235

Please upload reports for the commit 681a235 to get more accurate results.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15306      +/-   ##
==========================================
+ Coverage   37.03%   37.13%   +0.09%     
==========================================
  Files        6539     6504      -35     
  Lines      133079   132229     -850     
  Branches    38119    37804     -315     
==========================================
- Hits        49292    49101     -191     
+ Misses      83787    83128     -659     
Flag Coverage Δ
judicial-system-backend 56.15% <ø> (-0.01%) ⬇️

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

Files Coverage Δ
...ckend/src/app/modules/case/internalCase.service.ts 85.60% <ø> (ø)

... and 140 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 8e43c3c...681a235. Read the comment docs.

@unakb unakb marked this pull request as ready for review June 21, 2024 12:19
@unakb unakb requested a review from a team as a code owner June 21, 2024 12:19
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 (2)
apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts (2)

Line range hint 149-179: Invalid use of decorators in non-decorable contexts.

There are multiple errors related to the misuse of decorators in contexts where they are not valid. This typically occurs when decorators are applied to properties or methods incorrectly. To resolve these issues, ensure that decorators are only used in valid contexts such as class declarations or methods.

- @IncorrectDecorator
+ // Correct or remove the decorator

Line range hint 875-875: Performance issue with spread operator in accumulator.

Using the spread operator in the accumulator of a .reduce method leads to inefficient code with a time complexity of O(n^2). Consider using .push or direct assignment to enhance performance.

- accumulatedArray = [...accumulatedArray, newItem];
+ accumulatedArray.push(newItem);
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 110e634 and 712f2fb.

Files selected for processing (8)
  • apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts (1 hunks)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/case.response.ts (2 hunks)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/cases.response.ts (2 hunks)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/internal/internalCase.response.ts (3 hunks)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/shared/groups.model.ts (1 hunks)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/shared/items.model.ts (1 hunks)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts (4 hunks)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/utils/translations.strings.ts (1 hunks)
Additional context used
Path-based instructions (8)
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/shared/groups.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/digital-mailbox-api/src/app/modules/cases/models/shared/items.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/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/cases.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/case.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/utils/translations.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/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/backend/src/app/modules/case/internalCase.service.ts (1)

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

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

[error] 149-149: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 150-150: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 152-152: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 153-153: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 155-155: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 157-157: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 159-159: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 161-161: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 163-163: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 165-165: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 167-167: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 169-169: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 171-171: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 173-173: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 175-175: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 177-177: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 179-179: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 893-893: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 875-875: Avoid the use of spread (...) syntax on accumulators. (lint/performance/noAccumulatingSpread)

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

Additional comments not posted (8)
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/shared/groups.model.ts (1)

1-11: Excellent use of Swagger decorators for API documentation.

The Groups class is well-defined with clear properties label and items. Each property is correctly annotated with @ApiProperty, which enhances the Swagger documentation. This is particularly important for maintaining clarity in API documentation and ensuring that the API consumers understand the structure and purpose of each property.

apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/shared/items.model.ts (1)

1-12: Proper implementation of model properties with Swagger annotations.

The Items class is well-structured with properties label, value, and linkType, each equipped with @ApiProperty annotations. This not only aids in documentation but also ensures type safety and clear expectations for API consumers. The use of an enum for linkType is a good practice, as it restricts the values to 'email' or 'tel', thus reducing potential errors from incorrect data types.

[APROVED]

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

17-17: Well-structured addition of DateLog and its integration into InternalCaseResponse.

The addition of the DateLog interface and its optional inclusion in the InternalCaseResponse class as dateLogs is well thought out. This allows for flexible logging of dates relevant to internal cases, enhancing the data richness without imposing a requirement. The use of optional fields (location) in DateLog is a good practice, providing flexibility in data storage.

Also applies to: 34-40

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

6-6: Effective use of translation utilities to enhance data representation based on language.

The integration of getTranslations in the CasesResponse class is a significant enhancement. It allows the API to dynamically adjust labels and other textual representations based on the user's language, making the API more accessible and user-friendly. The method fromInternalCasesResponse effectively uses these translations to construct a response that is both informative and localized.

Also applies to: 29-38

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

29-33: Incorporation of translation utility and data mapping in CaseResponse.

The method fromInternalCaseResponse effectively utilizes the getTranslations utility to fetch language-specific labels and formats dates appropriately. This is crucial for internationalization. Additionally, the method constructs a complex response object by mapping data from the InternalCaseResponse object, which is a good use of JavaScript's array methods and optional chaining to ensure robustness against null values.

Also applies to: 39-89

apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/utils/translations.strings.ts (1)

1-103: Comprehensive implementation of translation utility.

The getTranslations function and the Translations type are well-implemented to support multiple languages, which enhances the application's accessibility for different user bases. The default language fallback mechanism is a good practice to ensure the application behaves predictably in case of unsupported language inputs.

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

3-11: Enhanced data structure and formatting in SubpoenaResponse.

The SubpoenaResponse class effectively uses imported utilities for data formatting and type safety, and the SubpoenaData class structure is well-defined with appropriate use of decorators for API documentation. The method fromInternalCaseResponse is robust, making good use of optional chaining and array transformations to handle potential null values gracefully.

Also applies to: 21-89

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

Line range hint 893-893: Recommended use of optional chaining.

There's a recommendation to use optional chaining to make the code more concise and safe against null or undefined values. This change will help prevent runtime errors due to attempts to access properties on null or undefined.
[REFACTOR_SUGGESTion]

- if (obj && obj.property) { ... }
+ if (obj?.property) { ... }

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 712f2fb and 68b133e.

Files selected for processing (2)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts (3 hunks)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/utils/translations.strings.ts (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/utils/translations.strings.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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 68b133e and a0757ba.

Files selected for processing (1)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts

Copy link
Member

@oddsson oddsson left a comment

Choose a reason for hiding this comment

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

Super nice!

@gudjong gudjong added the automerge Merge this PR as soon as all checks pass label Jun 25, 2024
@kodiakhq kodiakhq bot merged commit b04fa29 into main Jun 25, 2024
26 checks passed
@kodiakhq kodiakhq bot deleted the j-s/subpoena-info branch June 25, 2024 12:43
sigruntg pushed a commit that referenced this pull request Jun 27, 2024
* feat(j-s): Return subpoena info from digital mailbox API

* cleanup

* more cleanup

* fix(j-s): missing defense info

* Update subpoena.response.ts

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
snaerseljan pushed a commit that referenced this pull request Jul 2, 2024
* feat(j-s): Return subpoena info from digital mailbox API

* cleanup

* more cleanup

* fix(j-s): missing defense info

* Update subpoena.response.ts

---------

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.

3 participants