Skip to content

Conversation

CarsonF
Copy link
Member

@CarsonF CarsonF commented Apr 8, 2025

Trying #3382 again.

Accounting for import aliases this time, and avoiding match patterns that need to declare a new variable that is also an import name.

Copy link

coderabbitai bot commented Apr 8, 2025

📝 Walkthrough

Walkthrough

This pull request updates how subqueries are constructed across various repository and core query modules. Changes include replacing anonymous functions with an array of string or variable identifiers in subQuery calls, eliminating redundant .with clauses, and renaming node aliases to standardize query contexts. Additionally, core query methods and documentation have been refined to reflect the new syntax and improved structure without altering the functional behavior of the queries.

Changes

File(s) Change Summary
src/components/budget/budget-record.repository.ts, src/components/budget/budget.repository.ts, src/components/file/file.repository.ts Updated subQuery calls to accept arrays (e.g., ['project', 'budget'], 'node') instead of anonymous functions and removed obsolete .with clauses.
src/components/engagement/handlers/apply-finalized-changeset-to-engagement.handler.ts, src/components/language/language.repository.ts, src/components/notifications/notification.repository.ts Modified subQuery invocations to use array notation (e.g., ['project', 'changeset'], ['projList', 'props']), streamlining query definitions.
src/components/comments/comment-thread.repository.ts, src/components/engagement/engagement.repository.ts Restructured subqueries by renaming identifiers (e.g., replacing node with thread or outer) and introducing nested subquery logic for enhanced clarity.
src/components/organization/organization.repository.ts, src/components/partner/partner.repository.ts, src/components/partnership/handlers/apply-finalized-changeset-to-partnership.handler.ts, src/components/partnership/partnership.repository.ts Simplified subquery calls by directly passing string identifiers (e.g., 'projList') and arrays while removing redundant .with clauses and adjusting node aliasing.
src/components/periodic-report/periodic-report.repository.ts, src/components/progress-report/progress-report-extra-for-periodic-interface.repository.ts, src/components/progress-report/variance-explanation/variance-explanation.repository.ts Optimized hydration methods by refining subquery identifiers (using 'node' or arrays) and updating node references (e.g., renaming report to outer) along with restructuring matcher logic.
src/components/project/handlers/apply-finalized-changeset-to-project.handler.ts, src/components/project/project.repository.ts, src/components/user/user.repository.ts Updated subQuery calls in handling and assignment methods to use array parameters (e.g., ['node', 'changeset'], ['user', 'org']) and standardized node alias usage in sorters.
src/core/database/query-augmentation/subquery.ts, src/core/database/query/filters.ts, src/core/database/query/match-project-based-props.ts, src/core/database/query/properties/update-property.ts, src/core/database/query/sorting.ts Revised core subquery construction and associated query functions with updated method signatures, improved documentation, and elimination of redundant .with clauses, facilitating a more streamlined query building process.

Possibly related PRs

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

CodeRabbit Configuration 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

@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

🧹 Nitpick comments (1)
src/core/database/query/match-project-based-props.ts (1)

108-108: Consider using array syntax for consistency.

While passing a single string variable works, consider using an array syntax [projectVar] to maintain consistency with other subQuery calls in the codebase which use arrays for imports.

-    query.comment`matchProjectSens()`.subQuery(projectVar, (sub) =>
+    query.comment`matchProjectSens()`.subQuery([projectVar], (sub) =>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0292d91 and 7895dc5.

📒 Files selected for processing (23)
  • src/components/budget/budget-record.repository.ts (2 hunks)
  • src/components/budget/budget.repository.ts (1 hunks)
  • src/components/comments/comment-thread.repository.ts (1 hunks)
  • src/components/engagement/engagement.repository.ts (1 hunks)
  • src/components/engagement/handlers/apply-finalized-changeset-to-engagement.handler.ts (3 hunks)
  • src/components/file/file.repository.ts (1 hunks)
  • src/components/language/language.repository.ts (2 hunks)
  • src/components/notifications/notification.repository.ts (1 hunks)
  • src/components/organization/organization.repository.ts (1 hunks)
  • src/components/partner/partner.repository.ts (2 hunks)
  • src/components/partnership/handlers/apply-finalized-changeset-to-partnership.handler.ts (2 hunks)
  • src/components/partnership/partnership.repository.ts (2 hunks)
  • src/components/periodic-report/periodic-report.repository.ts (1 hunks)
  • src/components/progress-report/progress-report-extra-for-periodic-interface.repository.ts (3 hunks)
  • src/components/progress-report/variance-explanation/variance-explanation.repository.ts (1 hunks)
  • src/components/project/handlers/apply-finalized-changeset-to-project.handler.ts (1 hunks)
  • src/components/project/project.repository.ts (1 hunks)
  • src/components/user/user.repository.ts (2 hunks)
  • src/core/database/query-augmentation/subquery.ts (2 hunks)
  • src/core/database/query/filters.ts (1 hunks)
  • src/core/database/query/match-project-based-props.ts (3 hunks)
  • src/core/database/query/properties/update-property.ts (1 hunks)
  • src/core/database/query/sorting.ts (1 hunks)
🧰 Additional context used
🧬 Code Definitions (5)
src/components/partner/partner.repository.ts (1)
src/core/database/query/filters.ts (1)
  • sub (229-261)
src/components/project/handlers/apply-finalized-changeset-to-project.handler.ts (1)
src/core/database/query/filters.ts (1)
  • sub (229-261)
src/components/budget/budget.repository.ts (1)
src/core/database/query/filters.ts (1)
  • sub (229-261)
src/core/database/query-augmentation/subquery.ts (2)
src/core/database/query/filters.ts (1)
  • sub (229-261)
src/core/database/query-augmentation/SubClauseCollection.ts (1)
  • SubClauseCollection (4-43)
src/components/comments/comment-thread.repository.ts (1)
src/core/database/query/matching.ts (1)
  • ACTIVE (27-27)
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: E2E Tests (neo4j 6/6)
  • GitHub Check: E2E Tests (neo4j 5/6)
  • GitHub Check: E2E Tests (neo4j 4/6)
  • GitHub Check: E2E Tests (neo4j 3/6)
  • GitHub Check: E2E Tests (neo4j 2/6)
  • GitHub Check: Generate (head)
  • GitHub Check: E2E Tests (neo4j 1/6)
  • GitHub Check: Generate (base)
  • GitHub Check: lint
  • GitHub Check: Unit
  • GitHub Check: Clean
🔇 Additional comments (41)
src/components/progress-report/variance-explanation/variance-explanation.repository.ts (1)

44-51: Clean simplification of the subquery import syntax.

The change to directly pass ['report', 'node'] array to the subQuery method simplifies the code by removing the need for a separate context variable and the .with() clause. This is consistent with the new subquery import syntax being implemented across the codebase.

src/components/partnership/handlers/apply-finalized-changeset-to-partnership.handler.ts (2)

36-49: LGTM: Updated to the new subquery import syntax.

The change to directly pass ['project', 'changeset'] array to the subQuery method simplifies the code by eliminating the need for an explicit .with() clause while maintaining the same variables in the subquery context.


60-73: LGTM: Consistently implementing the new subquery import pattern.

This change mirrors the earlier modification in the same file, ensuring consistency in how subqueries are defined throughout the handler.

src/components/organization/organization.repository.ts (1)

94-106: LGTM: Successfully updated to the new subquery import syntax.

The change to directly pass 'projList' to the subQuery method eliminates the need for an explicit .with() clause while maintaining the same functionality. This simplifies the query structure and makes the code more readable.

src/components/notifications/notification.repository.ts (1)

151-168: LGTM: Updated to new subquery import pattern.

The change to directly pass 'node' to the subQuery method follows the new subquery import syntax being implemented across the codebase. The complex internal hydration logic remains intact while the query structure is simplified.

src/components/periodic-report/periodic-report.repository.ts (1)

383-392: Improved subquery structure with explicit variable import

The changes in the subQuery call make the code more explicit about which variables are being imported into the subquery. This approach is cleaner than the previous method of using an anonymous function and a .with('node') clause within it.

src/components/budget/budget.repository.ts (1)

191-196: Streamlined subquery with explicit variable imports

The change replaces the anonymous function that included a .with('project, budget') call with an explicit array of variables ['project', 'budget'] passed directly to the subQuery method. This eliminates the redundant .with() call and makes the code cleaner and more maintainable.

src/core/database/query/properties/update-property.ts (1)

200-210: Improved subquery structure and reduced redundancy

This change makes two important improvements:

  1. It now explicitly passes the imports array to the subQuery method, clearly showing which variables are being imported
  2. It removes a redundant .with(imports) call, making the query more efficient

This aligns well with the new subquery syntax being implemented across the codebase.

src/components/file/file.repository.ts (1)

138-151: Standardized subquery import syntax

The change replaces the anonymous function approach with an explicit string identifier for the variable being imported into the subquery. This follows the new pattern being implemented throughout the codebase for more consistent and readable query structures.

src/components/engagement/handlers/apply-finalized-changeset-to-engagement.handler.ts (3)

39-39: Improved subquery clarity with explicit variable imports

The change from an anonymous function to an array of explicit variable imports ['project', 'changeset'] makes the variable dependencies clearer upfront and eliminates the need for an explicit .with() clause. This aligns with the PR's goal of using the new subquery import syntax.


65-65: Consistent application of new subquery syntax

Good continuation of applying the new subquery import syntax pattern throughout the handler. The explicit array of imports ['project', 'changeset'] makes the query more readable by clearly declaring which variables are being used in the subquery context.


96-96: Completed consistent implementation of new subquery syntax

The third instance of subquery modification maintains consistency with the previous changes. This pattern improves query readability and maintenance by making variable dependencies explicit at the start of the subquery.

src/components/project/project.repository.ts (4)

367-368: Updated node reference from 'project' to 'outer'

Changed variable reference in getPath helper for the sorter to use 'outer' instead of 'project'. This matches the new standardized approach for sorters to reference the outer variable consistently.


375-375: Simplified variable reference in union clause

Replaced .with('node as project') with .with('outer'), simplifying the query and maintaining consistency with the variable naming used in the path definition.


382-383: Consistent variable naming in primaryPartnership sorter

The 'primaryPartnership' sorter now also uses 'outer' as its variable reference, ensuring consistency with the previous 'primaryLocation' sorter. This standardization makes the code more maintainable.


392-392: Completed standardization of sorter variable references

Final instance of changing variable reference to 'outer' in the union clause of the 'primaryPartnership' sorter, completing the consistent application of the new variable naming approach.

src/components/user/user.repository.ts (2)

280-281: Explicitly defined subquery variable imports

Updated subQuery to use the new syntax with explicit array of variables ['user', 'org'] instead of the previous anonymous function approach. This makes it clear which variables are being imported into the subquery scope.


294-294: Maintained consistency in nested subquery implementation

Applied the same subquery syntax update within the conditional code block, ensuring that both subqueries in this method use the new explicit imports pattern. Consistency across the codebase makes maintenance easier.

src/components/project/handlers/apply-finalized-changeset-to-project.handler.ts (1)

39-39: Adopted new subquery import syntax for budget record handling

Updated the subquery implementation to use explicit variable imports ['node', 'changeset'], which aligns with the changes made throughout the codebase. This clarifies which variables from the outer query are accessible within the subquery.

This change is part of the broader effort to standardize subquery syntax across the codebase as mentioned in the PR description. The explicit import approach prevents potential issues with variable scoping and makes the query dependencies clearer.

src/core/database/query/sorting.ts (1)

143-149: Improved subquery structure in the matcher function

The refactored matcher implementation creates a cleaner separation between outer and inner query contexts by explicitly defining the 'outer' node and using it in the subquery. This change follows the new subquery import syntax pattern being applied across the codebase, improving readability and consistency.

src/components/engagement/engagement.repository.ts (3)

901-908: Standardized variable naming in language sub-query

Renamed node reference to outer to follow the new subquery pattern, improving consistency with other parts of the codebase. This change simplifies the query structure by eliminating redundant variable renaming.


911-913: Standardized variable naming in project sub-query

Renamed the node reference to outer to maintain consistency with the new subquery pattern being implemented throughout the codebase.


916-934: Improved subquery structure in progress report sorting

Changed to use the more standardized pattern by explicitly defining outer as parent and then using it directly in the subQuery call. This approach creates a cleaner separation between query contexts and improves readability.

src/components/partner/partner.repository.ts (2)

212-224: Improved subQuery implementation in hydrate method

Changed to directly pass 'projList' as a parameter to subQuery instead of using an intermediate .with() clause. This simplifies the query structure and aligns with the new subquery import syntax pattern being applied across the codebase.


354-358: Standardized node variable name for consistency

Renamed the node reference from 'partner' to 'outer' to maintain consistency with the standardized variable naming convention used across all sorters. This alignment with the pattern used in filter.sub() (which defaults to 'outer') makes the code more maintainable and easier to understand.

src/components/language/language.repository.ts (2)

189-201: Enhanced subQuery implementation with explicit variable passing

Changed to pass an array of variables ['projList', 'props'] to subQuery, making it explicit which variables are needed in the subquery context. This follows the new subquery import syntax pattern, improving clarity and maintainability.


384-388: Standardized node variable name for consistency

Renamed the node reference from 'lang' to 'outer' to maintain consistency with the standardized variable naming convention used across all repositories. This change aligns with the pattern used in filter.sub() which defaults to 'outer' as the variable name.

src/components/progress-report/progress-report-extra-for-periodic-interface.repository.ts (3)

57-58: Standardized variable naming with outer

Good change! Renaming from node('report') to node('outer') aligns with the standardized naming convention used throughout the codebase for the outer node in sorter definitions.


68-69: Standardized variable naming with outer

Good change! Renaming from node('report') to node('outer') in the engagement sorter is consistent with the change in the pnpExtractionResult sorter above, and maintains consistency throughout sorter implementations.


82-102: Improved subQuery implementation for periodSummary matcher

Great restructuring of the periodSummary matcher! The new implementation:

  1. Uses the subQuery method with an explicit variable name 'report'
  2. Encapsulates the matching logic within a clean subquery context
  3. Maintains the same functionality while improving code clarity

This change is consistent with the PR objectives of standardizing query construction.

src/components/comments/comment-thread.repository.ts (1)

56-71: Improved subQuery structure for comment thread hydration

Nice restructuring of the nested subquery logic! The changes:

  1. Replace the previous implementation with a cleaner nested subQuery('thread', (sub2) => approach
  2. Make the variable scoping more explicit
  3. Improve the readability of the nested query structure
  4. Return 'comments' directly at the end of the subquery chain

This implementation is more maintainable and aligns with the standardized subquery pattern used throughout the codebase.

src/components/partnership/partnership.repository.ts (2)

283-313: Improved subQuery implementation with explicit variable passing

Good change! Replacing subQuery((sub) => with subQuery(['project', 'partner'], (sub) => makes it explicit which variables are being carried forward into the subquery, eliminating the need for separate .with clauses.

This implementation is more straightforward and aligns with the PR's goal of standardizing subquery syntax.


443-443: Standardized variable naming with outer

Good change! Renaming from node('partnership') to node('outer') in the partnershipSorters aligns with the standardized naming convention for the outer node in sorter definitions throughout the codebase.

src/components/budget/budget-record.repository.ts (2)

158-158: Improved subQuery implementation with explicit variable passing

Good change! Replacing subQuery((sub) => with subQuery([recordVar, projectVar], (sub) => makes it explicit which variables are being carried forward into the subquery. This eliminates ambiguity and improves the clarity of the query structure.


201-201: Improved subQuery implementation with explicit variable passing

Good change! Replacing subQuery((sub) => with subQuery(budgetVar, (sub) => makes it explicit which variable is being carried forward into the subquery. This is consistent with the pattern used throughout the PR.

src/core/database/query/filters.ts (1)

245-259: Implementation of the new subquery structure looks good.

The code changes here replace the previous single-level subquery with a nested structure that explicitly imports variables. The implementation properly:

  1. Creates an outer subquery that imports ['node', ...input]
  2. Creates an inner subquery that imports [...outerVar, ...input]
  3. Maintains the original functionality while making variable imports explicit

This aligns well with the new subquery syntax being adopted throughout the codebase.

src/core/database/query-augmentation/subquery.ts (3)

9-17: Clear, updated documentation for subQuery method.

The documentation has been properly updated to reflect the new CALL syntax with explicitly imported variables. The example is more practical and demonstrates the preferred usage pattern.


43-57: Cleaner implementation of the subQuery method.

The refactored code is more straightforward:

  1. Simplifies variable handling based on whether subOrImport is a function
  2. Directly builds the imports array from the provided variables
  3. Creates a more explicit flow for building and executing the subquery

This implementation makes the code easier to understand and maintain.


62-72: Improved SubQueryClause implementation.

The updated SubQueryClause now:

  1. Takes a scope parameter consisting of variables to be imported
  2. Properly formats the CALL clause with these imported variables
  3. Maintains the existing SubClauseCollection functionality

This change provides better support for the explicit variable import pattern.

src/core/database/query/match-project-based-props.ts (2)

25-50: Good application of the new subQuery syntax.

The updated implementation correctly uses the new array-based syntax for importing variables, making it clear which variables are being passed into the subquery context. The code maintains its original functionality while adopting the new pattern.


155-173: Good implementation of the new subQuery pattern.

The function has been properly updated to use the explicit variable import pattern. The code is well-formatted and maintains the original functionality while adopting the new syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant