-
Notifications
You must be signed in to change notification settings - Fork 4
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
updated search logic to only work with callouts on sets of type collaboration #4898
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request modifies the Changes
Sequence DiagramsequenceDiagram
participant Service as SearchResultService
participant DB as Database
Service->>DB: Retrieve Callouts
DB-->>Service: Return Callouts
Service->>Service: filterCalloutsBySetType
Service->>Service: Process Filtered Callouts
Possibly related PRs
Suggested reviewers
✨ Finishing Touches
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: 1
🧹 Nitpick comments (2)
src/services/api/search/v2/result/search.result.service.ts (2)
552-563
: Add error handling and optimize the query.The method could benefit from error handling and query optimization.
Consider these improvements:
private async getCalloutParents( callouts: Callout[] ): Promise<CalloutParents[]> { + try { + if (!callouts.length) return []; + const spaceCallouts = await this.filterCalloutsBySetType( callouts, CalloutsSetType.COLLABORATION ); const spaceCalloutIds = spaceCallouts.map(callout => callout.id); + if (!spaceCalloutIds.length) return []; const parentSpaces = await this.entityManager.find(Space, { where: { collaboration: { calloutsSet: { callouts: { id: In(spaceCalloutIds), }, }, }, }, + // Optimize by loading only necessary relations + relations: ['collaboration.calloutsSet.callouts'], - relations: { - collaboration: { - calloutsSet: { - callouts: true, - }, - }, - }, }); + } catch (error) { + this.logger.error( + `Failed to get callout parents: ${error}`, + error.stack, + LogContext.SEARCH + ); + throw error; + }
548-551
: Add JSDoc to clarify the filtering behavior.The method should document that it only returns parents for collaboration callouts.
Add documentation:
+/** + * Retrieves parent spaces for the given callouts, filtering to only include + * callouts from collaboration sets. + * @param callouts - The callouts to find parents for + * @returns Array of callout-space parent relationships + */ private async getCalloutParents( callouts: Callout[] ): Promise<CalloutParents[]> {
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/services/api/search/v2/result/search.result.service.ts
(4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/services/api/search/v2/result/search.result.service.ts (1)
Pattern src/**/*.{ts,js}
: Review the TypeScript/JavaScript code for NestJS best practices, dependency injection, module structure, and potential bugs.
Context Files (Do Not Review):
docs/Design.md
- Design overview of the projectdocs/Pagination.md
- Pagination design overviewdocs/Developing.md
- Development setup overviewdocs/graphql-typeorm-usage.md
- overview of GraphQL and TypeORM usage and how they are used together with NestJS in the projectdocs/database-definitions.md
- guidelines for creating TypeORM entity defnitionssrc/core/error-handling/graphql.exception.filter.ts
- GraphQL error handlingsrc/core/error-handling/http.exception.filter.ts
- HTTP error handlingsrc/core/error-handling/rest.error.response.ts
- REST error responsesrc/core/error-handling/unhandled.exception.filter.ts
- Global exception handler
Guidelines:
- Our project uses global exception handlers (
UnhandledExceptionFilter
), so avoid suggesting additionaltry/catch
blocks unless handling specific cases. - Use NestJS latest documentation from
https://docs.nestjs.com/
for reference on NestJS best practices. - Use TypeORM latest documentation from
https://typeorm.io/
for reference on TypeORM best practices. - Refer to the design overview in the context files for better understanding.
🔇 Additional comments (1)
src/services/api/search/v2/result/search.result.service.ts (1)
23-23
: LGTM! Clean import additions.The new imports for
ICallout
andCalloutsSetType
are properly placed and necessary for the added functionality.Also applies to: 36-36
The code looks good and fixes an error log. |
Only return search results for callouts in spaces
Summary by CodeRabbit
New Features
Improvements