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

fix(j-s): Null Service Reference #15247

Merged
merged 2 commits into from
Jun 18, 2024
Merged

fix(j-s): Null Service Reference #15247

merged 2 commits into from
Jun 18, 2024

Conversation

gudjong
Copy link
Member

@gudjong gudjong commented Jun 14, 2024

Null Service Reference

Laga villur á prod

What

  • Fixes a null service reference observed in prod logs.

Why

  • Verified bug.

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
    • Integrated PDF generation service into the case management system, allowing for automatic PDF creation for case documents.

@gudjong gudjong requested a review from a team as a code owner June 14, 2024 16:12
Copy link
Contributor

coderabbitai bot commented Jun 14, 2024

Walkthrough

The InternalCaseService class in the judicial system backend has been updated to include a new dependency for PDFService. This addition entails modifying the class constructor to support injecting PDFService using the @Inject and forwardRef decorators, enabling the service to generate or manipulate PDFs as part of its functionality.

Changes

File Summary
.../backend/src/app/modules/case/internalCase.service.ts Added dependency injection for PDFService using @Inject(forwardRef(() => PDFService))

Sequence Diagrams

Updated Dependency Injection Flow

sequenceDiagram
    participant Client
    participant InternalCaseService
    participant PDFService

    Client->>+InternalCaseService: Initiate Service
    InternalCaseService->>+PDFService: Dependency Injection with @Inject(forwardRef)
    Client->>-InternalCaseService: Use Service
Loading

This sequence diagram illustrates the updated dependency injection flow where the InternalCaseService now includes PDFService as a dependency, allowing it to generate or manipulate PDFs as needed.


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
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/backend/src/app/modules/case/internalCase.service.ts (2)

Line range hint 832-832: Consider optimizing the use of spread syntax in accumulators to improve performance.

-        .then((theCase) =>
-          this.defendantService.createForNewCase(
-            theCase.id,
-            {
-              nationalId: caseToCreate.accusedNationalId,
-              name: caseToCreate.accusedName,
-              gender: caseToCreate.accusedGender,
-              address: (caseToCreate.accusedAddress || '').trim(),
-              citizenship: caseToCreate.citizenship,
-            },
-            transaction,
-          ),
-        )
+        .then((theCase) => {
+          const defendant = {
+            nationalId: caseToCreate.accusedNationalId,
+            name: caseToCreate.accusedName,
+            gender: caseToCreate.accusedGender,
+            address: (caseToCreate.accusedAddress || '').trim(),
+            citizenship: caseToCreate.citizenship,
+          };
+          return this.defendantService.createForNewCase(theCase.id, defendant, transaction);
+        })
Tools
Biome

[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.


Line range hint 850-850: Change to an optional chain to make the code more readable and safe.

-    if (theCase.appealCaseNumber) {
+    if (theCase?.appealCaseNumber) {
Tools
Biome

[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.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7b0c0f8 and 6bd4155.

Files selected for processing (1)
  • apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts (1 hunks)
Additional context used
Path-based instructions (1)
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] 141-141: 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] 142-142: 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] 143-143: 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] 145-145: 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] 147-147: 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] 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] 151-151: 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] 850-850: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 832-832: 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 (1)
apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts (1)

167-167: The usage of @Inject decorator here is correctly implemented to resolve the null service reference issue. However, ensure PDFService is properly initialized before its use in the service methods to avoid runtime errors.

Tools
Biome

[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.

Copy link

codecov bot commented Jun 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.10%. Comparing base (5bbf5d8) to head (6bd4155).
Report is 1 commits behind head on main.

Current head 6bd4155 differs from pull request most recent head d7be182

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

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15247      +/-   ##
==========================================
- Coverage   37.10%   37.10%   -0.01%     
==========================================
  Files        6448     6448              
  Lines      131454   131447       -7     
  Branches    37574    37566       -8     
==========================================
- Hits        48780    48775       -5     
+ Misses      82674    82672       -2     
Flag Coverage Δ
api 3.51% <ø> (ø)
api-domains-auth-admin 54.29% <ø> (ø)
application-system-api 41.96% <ø> (ø)
application-template-api-modules 24.38% <ø> (-0.01%) ⬇️
auth-api-lib 14.29% <ø> (-0.02%) ⬇️
judicial-system-backend 55.79% <100.00%> (+<0.01%) ⬆️
services-auth-admin-api 51.36% <ø> (-0.04%) ⬇️
services-auth-delegation-api 61.66% <ø> (ø)
services-auth-ids-api 54.83% <ø> (-0.03%) ⬇️
services-auth-personal-representative 48.49% <ø> (ø)
services-auth-personal-representative-public 44.37% <ø> (-0.05%) ⬇️
services-auth-public-api 50.45% <ø> (-0.02%) ⬇️
services-user-notification 47.61% <ø> (+0.02%) ⬆️
services-user-profile 62.09% <ø> (-0.10%) ⬇️

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 86.08% <100.00%> (+0.03%) ⬆️

... and 5 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 f95ab14...d7be182. Read the comment docs.

@datadog-island-is
Copy link

Datadog Report

All test runs 52c9452 🔗

14 Total Test Services: 0 Failed, 14 Passed
🔻 Test Sessions change in coverage: 4 decreased, 1 increased (+0.01%), 20 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 4.16s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 14.92s 1 no change Link
application-system-api 0 0 0 111 2 2m 37.62s 1 no change Link
application-template-api-modules 0 0 0 109 0 1m 48s 1 no change Link
auth-api-lib 0 0 0 19 0 54.51s 1 no change Link
judicial-system-backend 0 0 0 20367 0 15m 59.4s 1 increased (+0.01%) Link
services-auth-admin-api 0 0 0 106 0 3m 26.84s 1 decreased (-0.01%) Link
services-auth-delegation-api 0 0 0 254 0 3m 27.32s 1 no change Link
services-auth-ids-api 0 0 0 215 0 1m 24.15s 1 no change Link
services-auth-personal-representative 0 0 0 59 0 1m 23.39s 1 decreased (-0.02%) Link

🔻 Code Coverage Decreases vs Default Branch (4)

  • services-user-profile - jest 52.26% (-0.05%) - Details
  • services-auth-personal-representative - jest 51.04% (-0.02%) - Details
  • services-auth-admin-api - jest 51.87% (-0.01%) - Details
  • services-auth-personal-representative-public - jest 46.91% (-0.01%) - Details

@oddsson oddsson added the automerge Merge this PR as soon as all checks pass label Jun 18, 2024
@kodiakhq kodiakhq bot merged commit 34c0031 into main Jun 18, 2024
23 checks passed
@kodiakhq kodiakhq bot deleted the j-s/null-service-fix branch June 18, 2024 09:24
lodmfjord pushed a commit that referenced this pull request Jun 18, 2024
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
kodiakhq bot added a commit that referenced this pull request Jun 18, 2024
…15239)

* Fix locale updates. Add cleanstring

* update string clean

* Update packagejson

* Update query

* Update query

* Add lang option

* Test

* Fix

* Add locale

* Test name update

* fix: force generated files

* chore: nx format:write update dirty files

* Revert test

* Remove ff

* fix: hash generated files

* fix(j-s): Null Service Reference (#15247)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* feat(native-app): Notifications final improvements (#15240)

* feat: buttons at top should not be sticky

* feat: add empty state for notifications

* fix: make sure to update unreadCount in inbox when fetching next page

* feat: add fallback icon for notifications

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* feat(consultation-portal): KAM-2522: PowerBI report added (#15251)

* fix: hash generated files (#15253)

* fix: hash generated files

* chore: nx format:write update dirty files

---------

Co-authored-by: andes-it <[email protected]>

* fix: remove file

* Update __config.mjs

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: lommi <[email protected]>
Co-authored-by: andes-it <[email protected]>
Co-authored-by: Guðjón Guðjónsson <[email protected]>
Co-authored-by: Þórey Jóna <[email protected]>
Co-authored-by: Karl Arnar Ægisson <[email protected]>
thordurhhh added a commit that referenced this pull request Jun 18, 2024
…15239)

* Fix locale updates. Add cleanstring

* update string clean

* Update packagejson

* Update query

* Update query

* Add lang option

* Test

* Fix

* Add locale

* Test name update

* fix: force generated files

* chore: nx format:write update dirty files

* Revert test

* Remove ff

* fix: hash generated files

* fix(j-s): Null Service Reference (#15247)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* feat(native-app): Notifications final improvements (#15240)

* feat: buttons at top should not be sticky

* feat: add empty state for notifications

* fix: make sure to update unreadCount in inbox when fetching next page

* feat: add fallback icon for notifications

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* feat(consultation-portal): KAM-2522: PowerBI report added (#15251)

* fix: hash generated files (#15253)

* fix: hash generated files

* chore: nx format:write update dirty files

---------

Co-authored-by: andes-it <[email protected]>

* fix: remove file

* Update __config.mjs

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: lommi <[email protected]>
Co-authored-by: andes-it <[email protected]>
Co-authored-by: Guðjón Guðjónsson <[email protected]>
Co-authored-by: Þórey Jóna <[email protected]>
Co-authored-by: Karl Arnar Ægisson <[email protected]>
kodiakhq bot added a commit that referenced this pull request Jun 18, 2024
…15255)

* fix(documents-v2): Add download URL to detail document v2 (#15194)

* fix(service-portal): Update notification icon styling (#15219)

* Update notification icon styling

* Add option to remove button docline

* fix(service-portal): Notifications - locale updates. Add cleanstring (#15239)

* Fix locale updates. Add cleanstring

* update string clean

* Update packagejson

* Update query

* Update query

* Add lang option

* Test

* Fix

* Add locale

* Test name update

* fix: force generated files

* chore: nx format:write update dirty files

* Revert test

* Remove ff

* fix: hash generated files

* fix(j-s): Null Service Reference (#15247)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* feat(native-app): Notifications final improvements (#15240)

* feat: buttons at top should not be sticky

* feat: add empty state for notifications

* fix: make sure to update unreadCount in inbox when fetching next page

* feat: add fallback icon for notifications

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* feat(consultation-portal): KAM-2522: PowerBI report added (#15251)

* fix: hash generated files (#15253)

* fix: hash generated files

* chore: nx format:write update dirty files

---------

Co-authored-by: andes-it <[email protected]>

* fix: remove file

* Update __config.mjs

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: lommi <[email protected]>
Co-authored-by: andes-it <[email protected]>
Co-authored-by: Guðjón Guðjónsson <[email protected]>
Co-authored-by: Þórey Jóna <[email protected]>
Co-authored-by: Karl Arnar Ægisson <[email protected]>

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: lommi <[email protected]>
Co-authored-by: andes-it <[email protected]>
Co-authored-by: Guðjón Guðjónsson <[email protected]>
Co-authored-by: Þórey Jóna <[email protected]>
Co-authored-by: Karl Arnar Ægisson <[email protected]>
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