-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
chore: converted isNewEntity lookup to use a set #38264
Conversation
WalkthroughThe pull request introduces modifications to the evaluation utilities in the CodeRabbit application, focusing on entity tracking and evaluation processes. The changes primarily affect how new entities are identified and processed during tree evaluations. The modifications streamline the logic for detecting new entities by switching from array-based to set-based lookups and enhance error handling in dynamic binding evaluations. Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
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: 2
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
app/client/src/ce/workers/Evaluation/evaluationUtils.ts
(2 hunks)app/client/src/workers/common/DataTreeEvaluator/index.ts
(2 hunks)
🔇 Additional comments (1)
app/client/src/workers/common/DataTreeEvaluator/index.ts (1)
1206-1206
: Consider verifying the behavior of "isNewEntity".
Because isNewEntity uses updates.has(entityName), it will never match unless the set contains the exact entity name. If the set instead stores “Table1.someProp”, the check for “Table1” will fail.
const allNewEntityDiffSet = new Set( | ||
unevalUpdates | ||
.filter((v) => v.event === DataTreeDiffEvent.NEW) | ||
.map((v) => v.payload.propertyPath), | ||
); |
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.
Potential mismatch when storing entity property paths in a set.
Currently, this code stores the entire property path (e.g., "Table1.selectedRow") in allNewEntityDiffSet, then checks for membership with just the entity name (e.g., "Table1"). This will fail if the property path includes anything more than the entity name.
A possible fix is to store just the entity names in the set, for example:
-const allNewEntityDiffSet = new Set(
- unevalUpdates
- .filter((v) => v.event === DataTreeDiffEvent.NEW)
- .map((v) => v.payload.propertyPath),
-);
+const allNewEntityDiffSet = new Set(
+ unevalUpdates
+ .filter((v) => v.event === DataTreeDiffEvent.NEW)
+ .map((v) => getEntityNameAndPropertyPath(v.payload.propertyPath).entityName),
+);
Committable suggestion skipped: line range outside the PR's diff.
export const isNewEntity = (updates: Set<string>, entityName: string) => { | ||
return updates.has(entityName); |
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.
Entity path vs. entity name mismatch.
This function only checks updates.has(entityName), but the set is populated with full property paths in index.ts unless corrected. Ensure that the stored values and this membership check are aligned.
If the goal is to confirm a new entity by name, consider storing only the entity name in the set or changing the membership check to parse out the entity name from the stored path.
## Description Converted the lookup the in isNewEntity to use a Set, this has reduced the cost of webworker scripting by about 5%. Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.All" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/12415891373> > Commit: 5dfc7a0 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12415891373&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.All` > Spec: > <hr>Thu, 19 Dec 2024 16:55:57 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced evaluation logic for newly created entities. - Improved error handling for dynamic bindings during evaluations. - **Bug Fixes** - Refined error tracking for property evaluations. - **Documentation** - Minor updates to comments and formatting for clarity. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
## Description Converted the lookup the in isNewEntity to use a Set, this has reduced the cost of webworker scripting by about 5%. Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.All" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/12415891373> > Commit: 5dfc7a0 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12415891373&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.All` > Spec: > <hr>Thu, 19 Dec 2024 16:55:57 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced evaluation logic for newly created entities. - Improved error handling for dynamic bindings during evaluations. - **Bug Fixes** - Refined error tracking for property evaluations. - **Documentation** - Minor updates to comments and formatting for clarity. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Description
Converted the lookup the in isNewEntity to use a Set, this has reduced the cost of webworker scripting by about 5%.
Fixes #
Issue Number
or
Fixes
Issue URL
Warning
If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.
Automation
/ok-to-test tags="@tag.All"
🔍 Cypress test results
Tip
🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12415891373
Commit: 5dfc7a0
Cypress dashboard.
Tags:
@tag.All
Spec:
Thu, 19 Dec 2024 16:55:57 UTC
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit
New Features
Bug Fixes
Documentation