-
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(signature-collection): Endpoint for parliamentary candidate list overview #16487
Conversation
WalkthroughThis pull request introduces several new methods and an API endpoint related to signature collections. A new query method 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
|
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 (4)
libs/api/domains/signature-collection/src/lib/signatureCollection.service.ts (1)
192-200
: LGTM: New method is well-structured and consistent.The
listOverview
method is correctly implemented and maintains consistency with other methods in the class. It adheres to the coding guidelines for reusability across different NextJS apps.Consider adding error handling to improve robustness:
async listOverview( user: User, listId: string, ): Promise<SignatureCollectionListSummary> { try { return await this.signatureCollectionClientService.getListOverview( user, listId, ); } catch (error) { // Log the error console.error('Error fetching list overview:', error); // Rethrow or handle as appropriate throw new Error('Failed to fetch list overview'); } }This addition would make the method more resilient and easier to debug.
libs/api/domains/signature-collection/src/lib/signatureCollection.resolver.ts (1)
212-222
: LGTM: New query method is well-implemented.The
signatureCollectionListOverview
method is correctly implemented with proper decorators for access control and auditing. It follows the established pattern of other query methods in this resolver and delegates to the service layer, which is a good practice.Minor suggestion for consistency:
Consider adding a@CurrentSignee()
parameter, as seen in other methods likesignatureCollectionList
. This might be useful if you need to perform any signee-specific checks in the service layer.async signatureCollectionListOverview( @CurrentUser() user: User, @CurrentSignee() signee: SignatureCollectionSignee, @Args('input') input: SignatureCollectionListIdInput, ): Promise<SignatureCollectionListSummary> { return this.signatureCollectionService.listOverview(user, signee, input.listId) }This change would make the method signature more consistent with other methods in the resolver and potentially provide more context to the service layer if needed.
libs/clients/signature-collection/src/lib/signature-collection.service.ts (1)
566-575
: LGTM: NewgetListOverview
method is well-implemented.The method follows the existing patterns in the class, correctly handles authentication, and uses async/await properly. Good job on parsing the
listId
to an integer for the API call.Consider adding error handling to catch and properly handle any API errors:
async getListOverview(auth: User, listId: string): Promise<ListSummary> { try { const summary = await this.getApiWithAuth( this.listsApi, auth, ).medmaelalistarIDInfoGet({ iD: parseInt(listId), }) return mapListSummary(summary) } catch (error) { // Log the error or handle it appropriately throw new Error(`Failed to get list overview: ${error.message}`) } }libs/clients/signature-collection/src/clientConfig.json (1)
1079-1113
: Endpoint addition looks good, consider enhancing the description.The new endpoint "/Medmaelalistar/{ID}/Info" is well-structured and consistent with the existing API patterns. It follows RESTful conventions and provides appropriate documentation.
Consider adding an English translation or explanation in the description for better international developer experience. For example:
"description": "Framboð geta sótt yfirlit fyrir sína eigin lista", +"description": "Framboð geta sótt yfirlit fyrir sína eigin lista (Candidates can retrieve an overview of their own lists)",
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (4)
- libs/api/domains/signature-collection/src/lib/signatureCollection.resolver.ts (2 hunks)
- libs/api/domains/signature-collection/src/lib/signatureCollection.service.ts (2 hunks)
- libs/clients/signature-collection/src/clientConfig.json (1 hunks)
- libs/clients/signature-collection/src/lib/signature-collection.service.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
libs/api/domains/signature-collection/src/lib/signatureCollection.resolver.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/api/domains/signature-collection/src/lib/signatureCollection.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/clients/signature-collection/src/clientConfig.json (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/clients/signature-collection/src/lib/signature-collection.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 (5)
libs/api/domains/signature-collection/src/lib/signatureCollection.service.ts (2)
21-21
: LGTM: Import statement is correctly placed and necessary.The new import for
SignatureCollectionListSummary
is appropriately placed with other imports and is required for the newlistOverview
method. This adheres to the coding guideline of TypeScript usage for defining types.
Line range hint
1-200
: Overall, the changes are well-implemented and align with the PR objectives.The additions to this file (new import and
listOverview
method) are consistent with the existing code structure and contribute to the goal of providing an overview of parliamentary candidate lists. The changes adhere to the coding guidelines for reusability and TypeScript usage.To further improve the implementation:
- Consider adding unit tests for the new
listOverview
method to ensure its functionality and maintain code quality.- Update the documentation (if any) to reflect the new capability added to the
SignatureCollectionService
.These suggestions will enhance the overall quality and maintainability of the code.
To ensure comprehensive test coverage, run the following command to check for existing tests and identify any gaps:
libs/api/domains/signature-collection/src/lib/signatureCollection.resolver.ts (2)
34-34
: LGTM: New import statement is correct and necessary.The import of
SignatureCollectionListSummary
is correctly added and is required for the new query method. It follows TypeScript best practices and the file path seems appropriate for the project structure.
Line range hint
1-222
: Summary: Changes align well with PR objectives.The new query method
signatureCollectionListOverview
and its associated import successfully implement the functionality described in the PR objectives. The changes are consistent with the existing code patterns and follow good practices for GraphQL resolvers in TypeScript.The new endpoint provides the required overview of the list of parliamentary candidates, as intended. The implementation is clean, well-structured, and properly integrated into the existing
SignatureCollectionResolver
class.libs/clients/signature-collection/src/lib/signature-collection.service.ts (1)
26-26
: LGTM: New import statement is correctly placed and follows best practices.The import of
ListSummary
andmapListSummary
is appropriately added and aligns with TypeScript best practices.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16487 +/- ##
=======================================
Coverage 36.79% 36.79%
=======================================
Files 6845 6845
Lines 141716 141720 +4
Branches 40363 40373 +10
=======================================
+ Hits 52138 52140 +2
- Misses 89578 89580 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Datadog ReportAll test runs ✅ 8 Total Test Services: 0 Failed, 8 Passed Test Services
🔻 Code Coverage Decreases vs Default Branch (3) |
...
Attach a link to issue if relevant
What
Specify what you're trying to achieve
Why
Specify why you need to achieve this
Screenshots / Gifs
Attach Screenshots / Gifs to help reviewers understand the scope of the pull request
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes
Documentation