-
Notifications
You must be signed in to change notification settings - Fork 61
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(deleagtion-api): Create seed for general mandate delegations #16721
Conversation
WalkthroughThis pull request introduces a new migration file that adds general mandate delegations to the database. It includes an Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #16721 +/- ##
=======================================
Coverage 36.53% 36.54%
=======================================
Files 6890 6890
Lines 143640 143639 -1
Branches 40926 40926
=======================================
Hits 52486 52486
+ Misses 91154 91153 -1
Flags with carried forward coverage won't be shown. Click here to find out more. see 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (3)
libs/auth-api-lib/seeders/20241105120627-add-general-mandate-delegations.js (3)
1-2
: Remove redundant 'use strict' directiveJavaScript modules are automatically in strict mode, making this directive unnecessary.
-'use strict' -🧰 Tools
🪛 Biome
[error] 1-1: Redundant use strict directive.
The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.(lint/suspicious/noRedundantUseStrict)
8-32
: Document test data and consider using environment variablesThe hardcoded national IDs and names should be documented and potentially moved to environment variables or a separate configuration file for better maintainability.
Consider adding a comment block explaining the test data:
/** * Test Data Mapping: * - 0101302399: Gervimaður Færeyjar (Faroe Islands test user) * - 0101302989: Gervimaður Ameríku (American test user) * - 0101305069: Gervimaður Bandaríkin (US test user) * - 0101304929: Gervimaður Bretland (UK test user) */
54-56
: Consider using parameterized values for the WHERE clauseThe WHERE clause could be more maintainable using parameterized values instead of hardcoded strings.
- WHERE to_national_id = '0101302399' AND from_national_id = '0101302989' AND domain_name is null - OR to_national_id = '0101305069' AND from_national_id = '0101304929' AND domain_name is null; + WHERE (to_national_id, from_national_id) IN ( + ('0101302399', '0101302989'), + ('0101305069', '0101304929') + ) AND domain_name is null;
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
libs/auth-api-lib/seeders/20241105120627-add-general-mandate-delegations.js
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/auth-api-lib/seeders/20241105120627-add-general-mandate-delegations.js (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."
🪛 Biome
libs/auth-api-lib/seeders/20241105120627-add-general-mandate-delegations.js
[error] 1-1: Redundant use strict directive.
The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.
(lint/suspicious/noRedundantUseStrict)
libs/auth-api-lib/seeders/20241105120627-add-general-mandate-delegations.js
Outdated
Show resolved
Hide resolved
libs/auth-api-lib/seeders/20241105120627-add-general-mandate-delegations.js
Outdated
Show resolved
Hide resolved
libs/auth-api-lib/seeders/20241105120627-add-general-mandate-delegations.js
Outdated
Show resolved
Hide resolved
Datadog ReportAll test runs ✅ 13 Total Test Services: 0 Failed, 13 Passed Test ServicesThis report shows up to 10 services
🔻 Code Coverage Decreases vs Default Branch (1)
|
There was a problem hiding this 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 (3)
libs/auth-api-lib/seeders/20241105120627-add-general-mandate-delegations.js (3)
1-1
: Remove redundant 'use strict' directiveThe 'use strict' directive is redundant as JavaScript modules are automatically in strict mode.
-'use strict'
🧰 Tools
🪛 Biome
[error] 1-1: Redundant use strict directive.
The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.(lint/suspicious/noRedundantUseStrict)
17-32
: Document test data purpose and relationshipsThe test data uses specific national IDs and reference IDs without clear documentation of their purpose or relationships.
Add comments explaining the test scenarios:
VALUES ( + -- Test Case 1: Delegation between Gervimaður Færeyjar and Gervimaður Ameríku uuid_generate_v4(), '0101302399', 'Gervimaður Færeyjar', '0101302989', 'Gervimaður Ameríku', null, 123 ), ( + -- Test Case 2: Delegation between Gervimaður Bandaríkin and Gervimaður Bretland uuid_generate_v4(), '0101305069', 'Gervimaður Bandaríkin', '0101304929', 'Gervimaður Bretland', null, 345 );
55-57
: Improve SQL WHERE clause formattingThe WHERE clause could be more readable with proper formatting and parentheses.
DELETE FROM delegation - WHERE to_national_id = '0101302399' AND from_national_id = '0101302989' AND domain_name is null - OR to_national_id = '0101305069' AND from_national_id = '0101304929' AND domain_name is null; + WHERE ( + (to_national_id = '0101302399' AND from_national_id = '0101302989' AND domain_name is null) + OR + (to_national_id = '0101305069' AND from_national_id = '0101304929' AND domain_name is null) + );
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
libs/auth-api-lib/seeders/20241105120627-add-general-mandate-delegations.js
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/auth-api-lib/seeders/20241105120627-add-general-mandate-delegations.js (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."
🪛 Biome
libs/auth-api-lib/seeders/20241105120627-add-general-mandate-delegations.js
[error] 1-1: Redundant use strict directive.
The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.
(lint/suspicious/noRedundantUseStrict)
🔇 Additional comments (1)
libs/auth-api-lib/seeders/20241105120627-add-general-mandate-delegations.js (1)
38-43
: 🛠️ Refactor suggestion
Add foreign key existence validation
The insertion into delegation_delegation_type
assumes 'GeneralMandate' exists in the delegation_types table. Consider adding a validation check.
INSERT INTO delegation_delegation_type (
delegation_id,
delegation_type_id
) VALUES (
+ -- Verify GeneralMandate exists
+ (SELECT CASE
+ WHEN EXISTS (SELECT 1 FROM delegation_type WHERE id = 'GeneralMandate')
+ THEN (select id from delegation where to_national_id = '0101302399' AND from_national_id = '0101302989' AND domain_name is null)
+ ELSE RAISE EXCEPTION 'GeneralMandate type does not exist'
+ END),
- (select id from delegation where to_national_id = '0101302399' AND from_national_id = '0101302989' AND domain_name is null),
'GeneralMandate'
), (
+ (SELECT CASE
+ WHEN EXISTS (SELECT 1 FROM delegation_type WHERE id = 'GeneralMandate')
+ THEN (select id from delegation where to_national_id = '0101305069' AND from_national_id = '0101304929' AND domain_name is null)
+ ELSE RAISE EXCEPTION 'GeneralMandate type does not exist'
+ END),
- (select id from delegation where to_national_id = '0101305069' AND from_national_id = '0101304929' AND domain_name is null),
'GeneralMandate'
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job. One question about the down query
libs/auth-api-lib/seeders/20241105120627-add-general-mandate-delegations.js
Show resolved
Hide resolved
…6721) * seed to create general mandate delegation between gervimenn * added transaction to the seed script --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
What
Create a seed script that inserts couple of general mandate delegations between gervimenn
Why
So the delegation will exist on staging
Screenshots / Gifs
Attach Screenshots / Gifs to help reviewers understand the scope of the pull request
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes