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): Confirmed court records #15921

Merged
merged 34 commits into from
Sep 12, 2024
Merged

feat(j-s): Confirmed court records #15921

merged 34 commits into from
Sep 12, 2024

Conversation

oddsson
Copy link
Member

@oddsson oddsson commented Sep 9, 2024

Confirmed court records

Asana

What

Create a confirmation stamp on court records in S-cases

Screenshots / Gifs

Screenshot 2024-09-09 at 13 14 11

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 functionality for generating PDF documents for legal case confirmations, including indictments, rulings, and court records.
    • Enhanced PDF generation logic to include specific checks for case file categories and conditions.
    • Added a new method for confirming court record documents, improving the visual elements in the generated PDFs.
  • Improvements

    • Streamlined logic for document confirmation and retrieval, ensuring only appropriate case files are confirmed based on case status and type.

@oddsson oddsson requested a review from a team as a code owner September 9, 2024 13:16
Copy link
Contributor

coderabbitai bot commented Sep 9, 2024

Walkthrough

This pull request updates the functionality for generating PDF documents related to legal case confirmations, specifically for indictments, rulings, and court records. It introduces a new type for handling case file categories, modifies the PDF generation logic to improve clarity and maintainability, and adds a new function for court record confirmations. The changes enhance error handling and streamline the process of confirming documents based on specific case file categories and conditions.

Changes

File Path Change Summary
apps/judicial-system/backend/src/app/formatters/confirmedPdf.ts Enhanced PDF generation for legal confirmations, introduced ConfirmableCaseFileCategories, added createCourtRecordConfirmation, and improved error handling.
apps/judicial-system/backend/src/app/modules/file/file.service.ts Added shouldGetConfirmedDocument method for streamlined document confirmation logic and improved case file retrieval.

Possibly related PRs

  • feat(j-s): Create ruling confirmation #15894: This PR modifies the confirmedPdf.ts file to add a new function for creating ruling confirmations, which is directly related to the changes made in the main PR regarding the handling of different case types in PDF generation.
  • fix(j-s): Cancelled Unassigned Indictment #15910: Although this PR focuses on the display of cancelled indictments, it involves the file.service.ts file, which is also modified in the main PR, indicating a potential connection in the handling of case files.
  • fix(j-s): Allow prison system users to see rulings #15935: This PR enhances the functionality for prison system users to access ruling case files, which aligns with the main PR's focus on improving the handling of legal document confirmations, particularly for rulings.

Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between eb6bd78 and 6524a80.

Files selected for processing (2)
  • apps/judicial-system/backend/src/app/formatters/confirmedPdf.ts (6 hunks)
  • apps/judicial-system/backend/src/app/modules/file/file.service.ts (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/judicial-system/backend/src/app/formatters/confirmedPdf.ts
Additional context used
Path-based instructions (1)
apps/judicial-system/backend/src/app/modules/file/file.service.ts (1)

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

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

240-265: LGTM!

The shouldGetConfirmedDocument method is a great addition that centralizes the logic for determining whether a document can be confirmed. It adheres to the Single Responsibility Principle, uses clear and descriptive variable names, and follows best practices such as using TypeScript for type safety and early returns to improve readability.


268-275: Great refactoring!

Replacing the multiple conditional checks with a single call to shouldGetConfirmedDocument simplifies the control flow and improves maintainability by centralizing the logic for determining whether a document can be confirmed.


Line range hint 409-417: Consistent refactoring!

Replacing the multiple conditional checks with a single call to shouldGetConfirmedDocument in getCaseFileSignedUrlFromS3 is consistent with the refactoring done in getCaseFileFromS3. It simplifies the control flow and improves maintainability by centralizing the logic for determining whether a document can be confirmed.


200-201: Correct confirmation logic for rulings and court records!

The logic for confirming rulings and court records is correct and consistent with the business requirements. It ensures that these documents are only confirmed when the case is completed.

Also applies to: 255-258


246-250: Correct confirmation logic for indictments!

The logic for confirming indictments is correct and consistent with the business requirements. It ensures that indictments are only confirmed when the case has been submitted to court.


263-264: Correct handling of other file categories!

The logic for handling other file categories is correct and consistent with the business requirements. It ensures that only indictments, rulings, and court records can be confirmed.


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

Outside diff range, codebase verification and nitpick comments (1)
apps/judicial-system/backend/src/app/modules/file/file.service.ts (1)

Line range hint 185-276: Approve changes and suggest enhanced logging.

The modifications in FileService enhance the handling of PDF creation based on case file categories and conditions. Consider adding more detailed logging for the new conditional branches to aid in debugging and maintenance, especially around the PDF generation process.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d1fbbda and a33b111.

Files selected for processing (3)
  • apps/judicial-system/backend/src/app/formatters/confirmedPdf.ts (1 hunks)
  • apps/judicial-system/backend/src/app/formatters/index.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/file/file.service.ts (4 hunks)
Additional context used
Path-based instructions (3)
apps/judicial-system/backend/src/app/formatters/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/src/app/formatters/confirmedPdf.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/file/file.service.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
Additional comments not posted (1)
apps/judicial-system/backend/src/app/formatters/index.ts (1)

37-37: Confirm renaming and verify references.

The renaming of createConfirmedIndictment to createConfirmedPdf suggests a broader scope for the function. Ensure that all references to the old function name are updated across the project to maintain consistency.

Verification successful

Renaming Verified Successfully

All references to createConfirmedIndictment have been updated to createConfirmedPdf across the codebase. No occurrences of the old function name were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to the old function name have been updated.

# Test: Search for the old function name. Expect: No occurrences.
rg --type typescript -A 5 $'createConfirmedIndictment'

Length of output: 88


Script:

#!/bin/bash
# Description: Verify all references to the old function name have been updated.

# Test: Search for the old function name. Expect: No occurrences.
rg --type ts -A 5 $'createConfirmedIndictment'

Length of output: 45

@datadog-island-is
Copy link

datadog-island-is bot commented Sep 9, 2024

Datadog Report

Branch report: j-s/confirmed-court-records
Commit report: 930c2eb
Test service: judicial-system-backend

❌ 1 Failed (0 Known Flaky), 21173 Passed, 0 Skipped, 18m 37.1s Total Time
🔻 Test Sessions change in coverage: 1 decreased (-0.09%)

❌ Failed Tests (1)

  • FileController - Upload case file to court AWS S3 get file should get the file from AWS S3 - apps/judicial-system/backend/src/app/modules/file/test/fileController/uploadCaseFileToCourt.spec.ts - Details

    Expand for error
     expect(jest.fn()).toHaveBeenCalledWith(...expected)
     
     Expected: "INDICTMENT", "b2a19322-86d7-48f3-aacb-7d3627396530/482dc432-992b-4627-a747-c6384768d8eb/test.txt"
     
     Number of calls: 0
    

🔻 Code Coverage Decreases vs Default Branch (1)

Copy link

codecov bot commented Sep 9, 2024

Codecov Report

Attention: Patch coverage is 21.05263% with 45 lines in your changes missing coverage. Please review.

Project coverage is 36.85%. Comparing base (d298945) to head (6524a80).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...-system/backend/src/app/formatters/confirmedPdf.ts 2.63% 37 Missing ⚠️
...ystem/backend/src/app/modules/file/file.service.ts 57.89% 8 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15921      +/-   ##
==========================================
- Coverage   36.86%   36.85%   -0.01%     
==========================================
  Files        6715     6715              
  Lines      137631   137664      +33     
  Branches    39132    39134       +2     
==========================================
+ Hits        50732    50737       +5     
- Misses      86899    86927      +28     
Flag Coverage Δ
judicial-system-backend 55.81% <21.05%> (-0.08%) ⬇️

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/file/file.service.ts 71.16% <57.89%> (+1.53%) ⬆️
...-system/backend/src/app/formatters/confirmedPdf.ts 14.75% <2.63%> (-4.14%) ⬇️

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 d298945...6524a80. Read the comment docs.

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 (1)
apps/judicial-system/backend/src/app/formatters/confirmedPdf.ts (1)

338-436: Approve implementation and suggest adding unit tests.

The implementation of createCourtRecordConfirmation is well-structured and follows the existing patterns for drawing visual elements on the PDF. Consider adding unit tests to cover different scenarios and ensure the function behaves as expected.

Would you like me to help in drafting some unit tests for this functionality?

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d0ee8f1 and eb6bd78.

Files selected for processing (1)
  • apps/judicial-system/backend/src/app/formatters/confirmedPdf.ts (6 hunks)
Additional context used
Path-based instructions (1)
apps/judicial-system/backend/src/app/formatters/confirmedPdf.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
Additional comments not posted (3)
apps/judicial-system/backend/src/app/formatters/confirmedPdf.ts (3)

14-17: LGTM!

The introduction of the ConfirmableCaseFileCategories type improves type safety and clarity in the code by replacing the direct usage of CaseFileCategory enums in the createConfirmedPdf function signature.


209-221: LGTM!

The changes to the dimensions of the shadow and title elements in the createRulingConfirmation function are approved.


441-459: LGTM!

The changes to the createConfirmedPdf function are approved. The refactoring from a series of if statements to a switch improves readability and maintainability. The inclusion of a default case that throws an error for unsupported fileType enhances error handling.

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.

Nice

@oddsson oddsson added the automerge Merge this PR as soon as all checks pass label Sep 12, 2024
@kodiakhq kodiakhq bot merged commit 8cce1bb into main Sep 12, 2024
24 checks passed
@kodiakhq kodiakhq bot deleted the j-s/confirmed-court-records branch September 12, 2024 11:28
jonnigs pushed a commit that referenced this pull request Sep 12, 2024
* Checkpoint

* Cleanup

* Rename

* Refactor

* Remove unused code

* Fix lint

* Create confirmed ruling

* Create confirmed ruling

* Make confirmation smaller

* Make confirmation smaller

* Use correct date

* Merge

* Refactor

* Refactor

* Cleanup

* Create court record pdf confirmation

* Cleanup

* Fix typos

* Merge

* Fix typo

* Fix shouldGetConfirmedDocument function

---------

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