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(ids-api): Add alive check to legal representative delegation type #16284

Merged
merged 18 commits into from
Nov 26, 2024

Conversation

valurefugl
Copy link
Member

@valurefugl valurefugl commented Oct 7, 2024

https://www.notion.so/Add-deceased-check-using-National-Registry-1115a76701d68092bb72fec8a14a94c4?pvs=4

What

Refactor alive status check into separate service. Add check to legal representative delegation type.

Enable using national registry v3 api for the check.

Why

So we don't show delegations for deceased individuals.

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

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 the AliveStatusService for determining the alive or deceased status of individuals and companies based on national IDs.
  • Improvements

    • Streamlined delegation services by integrating alive status checks directly, enhancing efficiency and reducing complexity.
  • Bug Fixes

    • Improved error handling during status checks to ensure robust functionality without complete failures.
  • Documentation

    • Updated module to include the new AliveStatusService, making it available for dependency injection.

@valurefugl valurefugl requested review from a team as code owners October 7, 2024 09:01
Copy link
Contributor

coderabbitai bot commented Oct 7, 2024

Walkthrough

The changes introduce the AliveStatusService, which determines the alive or deceased status of individuals and companies based on national IDs. This service replaces previous dependencies on NationalRegistryClientService and CompanyRegistryClientService in multiple classes, including DelegationsIncomingCustomService, DelegationsIncomingRepresentativeService, and DelegationsIncomingService. The methods in these classes have been refactored to utilize the new service, streamlining the logic for checking delegation statuses and removing unnecessary complexity.

Changes

File Change Summary
libs/auth-api-lib/src/lib/delegations/alive-status.service.ts Added AliveStatusService class with a method getStatus for checking alive/deceased status based on national IDs. Introduced type NameInfo.
libs/auth-api-lib/src/lib/delegations/delegations-incoming-custom.service.ts Updated DelegationsIncomingCustomService to use AliveStatusService. Changed method signatures to return NameInfo[] instead of FromNameInfo[]. Removed getLiveStatusFromDelegations method. Integrated new logic for checking delegation statuses using aliveStatusService.getStatus.
libs/auth-api-lib/src/lib/delegations/delegations-incoming-representative.service.ts Modified DelegationsIncomingRepresentativeService to replace NationalRegistryClientService with AliveStatusService. Updated findAllIncoming to use getStatus for filtering personal representatives based on alive/deceased status. Removed several private methods related to individual data fetching.
libs/auth-api-lib/src/lib/delegations/delegations-incoming.service.ts Refactored DelegationsIncomingService to utilize AliveStatusService for checking national ID statuses. Updated getAvailableDistrictCommissionersRegistryDelegations to filter deceased delegations based on new service. Changed updateName method to getNameFromNameInfo.
libs/auth-api-lib/src/lib/delegations/delegations.module.ts Added AliveStatusService to module providers. Adjusted import statements for consistency.

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • Herdismaria
  • saevarma
  • lodmfjord

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.

@valurefugl valurefugl changed the title Refactor alive status check into separate service. Add check to legal… feat(ids-api): Refactor alive status check into separate service. Add check to legal… Oct 7, 2024
@valurefugl valurefugl changed the title feat(ids-api): Refactor alive status check into separate service. Add check to legal… feat(ids-api): Add alive check to legal representative delegation type Oct 7, 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: 6

🧹 Outside diff range and nitpick comments (3)
libs/auth-api-lib/src/lib/delegations/alive-status.service.ts (2)

99-101: Consider inlining the error handler for simplicity

The handlerGetError method simply returns the error object without any additional processing. You can inline the error handling in the catch blocks to simplify the code.

You can replace .catch(this.handlerGetError) with .catch((error) => error) directly in the promises.


58-97: Consider removing the outer try-catch block for clarity

Since each individual promise handles its own errors by returning an error object, the Promise.all call will not reject, and the outer try-catch block might be unnecessary. Removing it could simplify the code and improve readability.

libs/auth-api-lib/src/lib/delegations/delegations-incoming-custom.service.ts (1)

Line range hint 232-285: Refactor duplicated logic for checking alive status into a separate method.

The logic for checking the alive status of delegations and handling deceased delegations is duplicated in both findAllIncomingGeneralMandates and findAllIncoming methods. To adhere to the DRY (Don't Repeat Yourself) principle and improve maintainability, consider extracting this logic into a private helper method.

Here's how you might refactor the code:

private async filterAliveDelegations(delegations: Delegation[]): Promise<{ delegations: Delegation[]; fromNameInfo: NameInfo[] }> {
  // Check live status, i.e., dead or alive for delegations
  const { aliveNationalIds, deceasedNationalIds, aliveNameInfo } =
    await this.aliveStatusService.getStatus(
      delegations.map((d) => d.fromNationalId),
    );

  if (deceasedNationalIds.length > 0) {
    const deceasedDelegations = delegations.filter((d) =>
      deceasedNationalIds.includes(d.fromNationalId),
    );
    // Delete all deceased delegations by deleting them and their scopes.
    const deletePromises = deceasedDelegations.map((delegation) =>
      delegation.destroy(),
    );

    await Promise.all(deletePromises);

    this.auditService.audit({
      action: 'deleteDelegationsForMissingPeople',
      resources: deceasedDelegations.map(({ id }) => id).filter(isDefined),
      system: true,
    });
  }

  return {
    delegations: delegations.filter((d) =>
      aliveNationalIds.includes(d.fromNationalId),
    ),
    fromNameInfo: aliveNameInfo,
  };
}

Then, modify the original methods to use this helper:

async findAllIncomingGeneralMandates(...) {
  // Existing code to fetch delegations
  const delegations = await this.delegationModel.findAll({ ... });

- // Original logic duplicated here
- // [Code for checking alive status]

+ // Use the new helper method
+ const { delegations: aliveDelegations, fromNameInfo } = await this.filterAliveDelegations(delegations);

  // Continue processing with aliveDelegations and fromNameInfo
}

async findAllIncoming(...) {
  // Existing code to fetch delegations
  const delegations = await this.delegationModel.findAll({ ... });

+ // Use the new helper method
+ const { delegations: aliveDelegations, fromNameInfo } = await this.filterAliveDelegations(delegations);

  // Continue processing with aliveDelegations and fromNameInfo
}

Also applies to: 335-363

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 42d7d9a and 4c3279d.

📒 Files selected for processing (5)
  • libs/auth-api-lib/src/lib/delegations/alive-status.service.ts (1 hunks)
  • libs/auth-api-lib/src/lib/delegations/delegations-incoming-custom.service.ts (9 hunks)
  • libs/auth-api-lib/src/lib/delegations/delegations-incoming-representative.service.ts (3 hunks)
  • libs/auth-api-lib/src/lib/delegations/delegations-incoming.service.ts (5 hunks)
  • libs/auth-api-lib/src/lib/delegations/delegations.module.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
libs/auth-api-lib/src/lib/delegations/alive-status.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."
libs/auth-api-lib/src/lib/delegations/delegations-incoming-custom.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."
libs/auth-api-lib/src/lib/delegations/delegations-incoming-representative.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."
libs/auth-api-lib/src/lib/delegations/delegations-incoming.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."
libs/auth-api-lib/src/lib/delegations/delegations.module.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."
🔇 Additional comments (8)
libs/auth-api-lib/src/lib/delegations/delegations.module.ts (3)

12-12: LGTM: Import organization improvement

The relocation of the FeatureFlagModule import improves code organization by grouping external imports together.


16-16: LGTM: Import organization improvement

The relocation of the environment import improves code organization by grouping internal imports together.


26-26: Verify the implementation of AliveStatusService

The addition of AliveStatusService to the providers array aligns with the PR objective to refactor the alive status check into a separate service. This change looks good, but let's verify its implementation.

Let's check the implementation of AliveStatusService:

Also applies to: 87-87

✅ Verification successful

AliveStatusService implementation verified successfully

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of AliveStatusService

# Test 1: Check if AliveStatusService file exists
echo "Checking if AliveStatusService file exists:"
fd -t f "alive-status.service.ts"

# Test 2: Inspect the content of AliveStatusService
echo "Inspecting the content of AliveStatusService:"
ast-grep --lang typescript --pattern $'class AliveStatusService {
  $$$
}'

# Test 3: Check for usage of AliveStatusService in other files
echo "Checking for usage of AliveStatusService in other files:"
rg "AliveStatusService" --type ts

Length of output: 10397

libs/auth-api-lib/src/lib/delegations/alive-status.service.ts (1)

15-18: Proper use of TypeScript for defining types

The NameInfo type is well-defined, enhancing type safety and code readability.

libs/auth-api-lib/src/lib/delegations/delegations-incoming-custom.service.ts (2)

17-23: Ensure TypeScript types are defined and exported correctly.

The imports of AliveStatusService, NameInfo, and related models are appropriate. This aligns with the coding guidelines for TypeScript usage in defining and exporting types, enhancing reusability across different NextJS apps.


46-46: Dependency injection of AliveStatusService is correctly implemented.

The aliveStatusService is properly injected into the constructor, ensuring that the service is available throughout the class. This adheres to best practices for dependency injection in NestJS.

libs/auth-api-lib/src/lib/delegations/delegations-incoming.service.ts (2)

409-415: Well-implemented method for retrieving name from NameInfo

The getNameFromNameInfo method efficiently retrieves the name associated with a national ID, defaulting to UNKNOWN_NAME if not found. This adheres to good TypeScript practices and enhances code readability.


362-367: Ensure 'aliveNationalIds' is not empty before filtering

If aliveNationalIds is empty or undefined, the subsequent filtering may not behave as expected. Confirm that aliveNationalIds contains the expected data before using it to filter records.

Run the following script to check if aliveNationalIds is ever empty:

✅ Verification successful

'aliveNationalIds' is properly populated before filtering. No issues found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for instances where 'aliveNationalIds' might be empty.

# Test: Look for assignments to 'aliveNationalIds' and check usage.
rg --type typescript -A 3 'const { aliveNationalIds' | rg 'length === 0'

Length of output: 189


Script:

#!/bin/bash
# Description: Search for instances where 'aliveNationalIds' might be empty.

# Corrected Test: Look for assignments to 'aliveNationalIds' and check usage.
rg --type typescript -A 3 'const \{ aliveNationalIds' | rg 'length === 0'

Length of output: 110


Script:

#!/bin/bash
# Description: Search for instances where 'aliveNationalIds' might be empty.

# Corrected Test: Look for assignments to 'aliveNationalIds' and check usage.
rg --type ts -A 3 'const \{ aliveNationalIds' | rg 'length === 0'

Length of output: 67


Script:

#!/bin/bash
# Description: Search for instances where 'aliveNationalIds' might be empty.

# Corrected Test: Look for assignments to 'aliveNationalIds' and check usage.
rg -g "*.ts" -F 'aliveNationalIds.length === 0' -A 3

Length of output: 54

Copy link

codecov bot commented Oct 7, 2024

Codecov Report

Attention: Patch coverage is 85.24590% with 27 lines in your changes missing coverage. Please review.

Project coverage is 35.58%. Comparing base (3d9f462) to head (295d8d4).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...rc/lib/delegations/delegations-incoming.service.ts 58.62% 12 Missing ⚠️
...delegations/delegations-incoming-custom.service.ts 78.94% 8 Missing ⚠️
...pi-lib/src/lib/delegations/alive-status.service.ts 92.20% 6 Missing ⚠️
...ons/delegations-incoming-representative.service.ts 94.44% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16284      +/-   ##
==========================================
+ Coverage   35.55%   35.58%   +0.03%     
==========================================
  Files        6931     6916      -15     
  Lines      146661   147219     +558     
  Branches    41695    42361     +666     
==========================================
+ Hits        52139    52388     +249     
- Misses      94522    94831     +309     
Flag Coverage Δ
air-discount-scheme-backend 47.89% <100.00%> (+0.01%) ⬆️
air-discount-scheme-web 0.00% <ø> (ø)
api 3.34% <ø> (ø)
api-domains-air-discount-scheme 37.12% <100.00%> (+0.03%) ⬆️
api-domains-assets 26.71% <ø> (ø)
api-domains-auth-admin 48.49% <ø> (ø)
api-domains-communications 39.58% <100.00%> (+<0.01%) ⬆️
api-domains-criminal-record 47.60% <100.00%> (+0.03%) ⬆️
api-domains-driving-license 44.52% <100.00%> (+0.01%) ⬆️
api-domains-education 30.61% <100.00%> (+0.03%) ⬆️
api-domains-health-insurance 34.48% <100.00%> (+0.04%) ⬆️
api-domains-mortgage-certificate 34.77% <100.00%> (+0.02%) ⬆️
api-domains-payment-schedule 41.34% <100.00%> (+0.02%) ⬆️
application-api-files 62.14% <100.00%> (+0.03%) ⬆️
application-core 69.97% <ø> (-0.94%) ⬇️
application-system-api 38.75% <100.00%> (+0.01%) ⬆️
application-template-api-modules 27.78% <100.00%> (+0.01%) ⬆️
application-templates-accident-notification 28.97% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 25.86% <ø> (ø)
application-templates-driving-license 18.18% <ø> (ø)
application-templates-estate 12.16% <ø> (ø)
application-templates-example-payment 24.80% <ø> (ø)
application-templates-financial-aid 15.80% <ø> (ø)
application-templates-general-petition 23.09% <ø> (ø)
application-templates-inheritance-report 6.58% <ø> (ø)
application-templates-marriage-conditions 15.12% <ø> (ø)
application-templates-mortgage-certificate 43.27% <ø> (ø)
application-templates-parental-leave 29.93% <ø> (ø)
application-types 6.51% <ø> (ø)
application-ui-components 1.27% <ø> (ø)
application-ui-shell 20.17% <ø> (ø)
clients-charge-fjs-v2 24.11% <ø> (ø)
clients-driving-license 40.32% <100.00%> (+0.04%) ⬆️
clients-driving-license-book 43.53% <100.00%> (+0.02%) ⬆️
clients-financial-statements-inao 49.10% <100.00%> (+0.03%) ⬆️
clients-license-client 1.26% <ø> (ø)
clients-regulations 42.40% <100.00%> (+0.04%) ⬆️
clients-rsk-company-registry 29.76% <ø> (ø)
clients-rsk-personal-tax-return 38.00% <ø> (ø)
clients-smartsolutions 12.77% <ø> (ø)
clients-syslumenn 49.25% <100.00%> (+0.02%) ⬆️
clients-zendesk 50.73% <100.00%> (+0.12%) ⬆️
cms 0.40% <ø> (ø)
cms-translations 38.91% <100.00%> (+<0.01%) ⬆️
dokobit-signing 62.85% <100.00%> (+0.08%) ⬆️
email-service 60.65% <100.00%> (+0.08%) ⬆️
feature-flags 90.69% <100.00%> (+0.07%) ⬆️
file-storage 45.91% <100.00%> (+0.11%) ⬆️
financial-aid-backend 51.30% <100.00%> (+0.01%) ⬆️
judicial-system-api 20.01% <ø> (ø)
judicial-system-audit-trail 68.94% <100.00%> (+0.08%) ⬆️
judicial-system-backend 55.58% <100.00%> (+<0.01%) ⬆️
judicial-system-message 67.12% <100.00%> (+0.06%) ⬆️
judicial-system-message-handler 48.17% <100.00%> (+0.09%) ⬆️
judicial-system-scheduler 71.01% <100.00%> (+0.02%) ⬆️
license-api 42.65% <100.00%> (+0.06%) ⬆️
nest-aws ?
nest-config 78.07% <100.00%> (+0.06%) ⬆️
nest-core ?
nest-feature-flags 51.15% <100.00%> (+0.06%) ⬆️
nova-sms 62.18% <100.00%> (+0.09%) ⬆️
portals-admin-regulations-admin 1.85% <ø> (ø)
portals-core 15.90% <ø> (ø)
services-auth-admin-api 52.56% <36.36%> (+0.05%) ⬆️
services-auth-delegation-api 58.55% <74.39%> (+1.03%) ⬆️
services-auth-ids-api 52.25% <84.66%> (+0.18%) ⬆️
services-auth-public-api 49.25% <77.57%> (+0.33%) ⬆️
services-sessions 65.47% <100.00%> (-0.03%) ⬇️
services-university-gateway 49.24% <100.00%> (-0.14%) ⬇️
services-user-notification 46.75% <100.00%> (+<0.01%) ⬆️
services-user-profile 56.82% <100.00%> (+0.16%) ⬆️
testing-e2e ?
web 1.73% <ø> (ø)

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

Files with missing lines Coverage Δ
apps/services/auth/admin-api/src/app/app.module.ts 100.00% <100.00%> (ø)
...services/auth/delegation-api/src/app/app.module.ts 100.00% <100.00%> (ø)
...auth/personal-representative/src/app/app.module.ts 100.00% <100.00%> (ø)
...pps/services/auth/public-api/src/app/app.module.ts 100.00% <100.00%> (ø)
libs/auth-api-lib/src/index.ts 92.43% <100.00%> (-7.57%) ⬇️
...-api-lib/src/lib/delegations/delegations.module.ts 100.00% <100.00%> (ø)
...elegations/national-registry-v3-feature.service.ts 100.00% <100.00%> (ø)
libs/feature-flags/src/lib/features.ts 100.00% <100.00%> (ø)
...ons/delegations-incoming-representative.service.ts 61.44% <94.44%> (-23.85%) ⬇️
...pi-lib/src/lib/delegations/alive-status.service.ts 92.20% <92.20%> (ø)
... and 2 more

... and 172 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 3d9f462...295d8d4. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 7, 2024

Datadog Report

All test runs 33c5fa0 🔗

68 Total Test Services: 0 Failed, 66 Passed
🔻 Test Sessions change in coverage: 6 decreased, 19 increased, 175 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
air-discount-scheme-backend 0 0 0 82 0 31.28s N/A Link
air-discount-scheme-web 0 0 0 2 0 8.87s 1 no change Link
api 0 0 0 4 0 3.24s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 20.01s N/A Link
api-domains-assets 0 0 0 3 0 12.81s N/A Link
api-domains-auth-admin 0 0 0 18 0 13.96s N/A Link
api-domains-communications 0 0 0 5 0 33.41s 1 no change Link
api-domains-criminal-record 0 0 0 5 0 9.72s 1 increased (+0.05%) Link
api-domains-driving-license 0 0 0 23 0 29.58s 1 no change Link
api-domains-education 0 0 0 8 0 21.47s 1 increased (+0.03%) Link

🔻 Code Coverage Decreases vs Default Branch (6)

This report shows up to 5 code coverage decreases.

  • services-auth-admin-api - jest 46.87% (-1.04%) - Details
  • services-auth-personal-representative-public - jest 40.12% (-0.94%) - Details
  • services-auth-personal-representative - jest 43.37% (-0.92%) - Details
  • services-auth-public-api - jest 45% (-0.84%) - Details
  • services-auth-delegation-api - jest 50.42% (-0.58%) - 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: 2

🧹 Outside diff range and nitpick comments (1)
libs/auth-api-lib/src/lib/delegations/delegations-incoming.service.ts (1)

337-341: Consider adding error handling for AliveStatusService.getStatus call

While the implementation is correct, it's important to handle potential errors that may occur when calling aliveStatusService.getStatus. This will improve the robustness of the code.

Consider wrapping the call in a try-catch block:

+   try {
      const { aliveNationalIds, deceasedNationalIds, aliveNameInfo } =
        await this.aliveStatusService.getStatus(
          uniq(records.map((d) => d.fromNationalId)),
        )
+   } catch (error) {
+     logger.error('Failed to retrieve alive status', { error })
+     // Handle the error appropriately, e.g., return an empty array or rethrow
+     throw new Error('Unable to retrieve alive status')
+   }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between aa84bb2 and 898a0cc.

📒 Files selected for processing (1)
  • libs/auth-api-lib/src/lib/delegations/delegations-incoming.service.ts (5 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/auth-api-lib/src/lib/delegations/delegations-incoming.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."
🔇 Additional comments (4)
libs/auth-api-lib/src/lib/delegations/delegations-incoming.service.ts (4)

19-19: LGTM: Import changes align with service updates

The import changes correctly reflect the introduction of AliveStatusService and NameInfo, while removing the no longer used NationalRegistryClientService. This aligns well with the refactoring of the alive status check into a separate service.


67-67: LGTM: Constructor updated to use AliveStatusService

The constructor has been correctly updated to inject AliveStatusService instead of NationalRegistryClientService. This change is consistent with the refactoring goal of moving the alive status check into a separate service.


337-341: LGTM: Implemented alive status check using AliveStatusService

The implementation correctly uses the new AliveStatusService to retrieve the alive/deceased status of individuals. This aligns with the PR objective of refactoring the alive status check into a separate service.


413-419: LGTM: Efficient implementation of getNameFromNameInfo method

The new getNameFromNameInfo method is well-implemented, using optional chaining (?.) and nullish coalescing (??) operators for safe and concise property access. It correctly handles the case where a name might not be found, falling back to UNKNOWN_NAME. This implementation aligns well with modern JavaScript best practices.

@valurefugl valurefugl requested a review from a team as a code owner November 18, 2024 15:13
@valurefugl valurefugl requested review from a team as code owners November 19, 2024 09:14
Copy link
Member

@programm-ingovals programm-ingovals left a comment

Choose a reason for hiding this comment

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

Regarding Personal Representative I see no issues.

Copy link
Member

@saevarma saevarma left a comment

Choose a reason for hiding this comment

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

🙌

@valurefugl valurefugl added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Nov 26, 2024
@kodiakhq kodiakhq bot merged commit ca7fe1a into main Nov 26, 2024
199 checks passed
@kodiakhq kodiakhq bot deleted the ids-api/add-alive-check branch November 26, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated:automerge (Disabled) Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants