Skip to content
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

Fix dynamic groups modal shortcuts + dynamic groups refactoring to use schema #4510

Merged
merged 4 commits into from
Jul 5, 2024

Conversation

sashankaryal
Copy link
Contributor

@sashankaryal sashankaryal commented Jun 18, 2024

This PR fixes the bug where hover handlers were not being used to update fos.hoveredSample. I also removed usage of getSanitizedGroupByExpression that had a special case for _sample_id. Instead, we construct the dynamic groups key value from dbFields in the schema.

Summary by CodeRabbit

  • New Features

    • Added the pathWithDbField property to the Field interface to store concatenated paths of dbField values for enhanced schema information.
  • Bug Fixes

    • Improved hover event handling in the SampleWrapper component to enhance user interaction.
  • Refactor

    • Simplified parameter handling in useHoveredSample by destructuring an object for update and clear functions.
  • Tests

    • Updated tests to validate new pathWithDbField property in schema queries.
  • Chores

    • Removed deprecated getSanitizedGroupByExpression function across multiple files to streamline codebase.

@sashankaryal sashankaryal self-assigned this Jun 18, 2024
Copy link
Contributor

coderabbitai bot commented Jun 18, 2024

Walkthrough

These updates streamline event handling, enhance user interactions, and improve code maintainability across several components and hooks. Major changes include refinements in hover event handling, removal of redundant functions like getSanitizedGroupByExpression, and additions to the Field interface for better data management.

Changes

Files Change Summaries
.../components/Modal/Sample.tsx Refactored hover event handling, improved conditional rendering for better user experience.
.../hooks/useCreateLooker.ts Removed getSanitizedGroupByExpression, replaced with direct groupBy usage.
.../hooks/useExpandSample.ts Removed import and usage of getSanitizedGroupByExpression, used dynamicGroupParameters.groupBy.
.../hooks/useHoveredSample.ts Refactored function parameters for useHoveredSample, streamlining parameter handling.
.../recoil/dynamicGroups.ts Removed getSanitizedGroupByExpression, added import getFieldInfo and adjusted groupBy usage.
.../recoil/utils.ts Removed getSanitizedGroupByExpression function.
.../src/schema.ts Added pathWithDbField to Field interface, updated getFieldInfo function.
.../src/schema.test.ts Added tests for new field pathWithDbField in SCHEMA, validated updated getFieldInfo function.

Poem

🐇
In fields of code where changes grow,
A rabbit's touch brings new flow,
Hover dances, fields align,
Cleaner, clearer, just in time.
Functions trimmed, events refined,
In the warren's lanes, brilliance shines.
~ CodeRabbit 🐰✨

Tip

AI model upgrade

gpt-4o model for reviews and chat is now live

OpenAI claims that this model is better at understanding and generating code than the previous models. Please join our Discord Community to provide any feedback or to report any issues.


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?

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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
Contributor

@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: 1

Outside diff range and nitpick comments (2)
app/packages/state/src/recoil/utils.ts (1)

Line range hint 145-155: Replacing .map().flat() with .flatMap() simplifies the code and improves performance by reducing the complexity of the operation.

-    .map((parent) =>
-      fieldsMatcher(
-        parent.fields || [],
-        labelsMatcher(parent),
-        undefined,
-        `${prefix}${parent.name}.`
-      )
-    )
-    .flat();
+    .flatMap((parent) =>
+      fieldsMatcher(
+        parent.fields || [],
+        labelsMatcher(parent),
+        undefined,
+        `${prefix}${parent.name}.`
+      )
+    );
app/packages/state/src/hooks/useCreateLooker.ts (1)

Line range hint 81-81: Avoid shadowing the global constructor property to prevent confusion and potential errors.

- let constructor:
+ let lookerConstructor:
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d095b22 and 79a74a8.

Files selected for processing (6)
  • app/packages/core/src/components/Modal/Sample.tsx (1 hunks)
  • app/packages/state/src/hooks/useCreateLooker.ts (2 hunks)
  • app/packages/state/src/hooks/useExpandSample.ts (2 hunks)
  • app/packages/state/src/hooks/useHoveredSample.ts (1 hunks)
  • app/packages/state/src/recoil/dynamicGroups.ts (3 hunks)
  • app/packages/state/src/recoil/utils.ts (1 hunks)
Additional context used
Path-based instructions (6)
app/packages/state/src/hooks/useHoveredSample.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/core/src/components/Modal/Sample.tsx (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/state/src/recoil/utils.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/state/src/hooks/useExpandSample.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/state/src/recoil/dynamicGroups.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/state/src/hooks/useCreateLooker.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

Biome
app/packages/state/src/hooks/useHoveredSample.ts

[error] 12-12: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 16-16: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 20-20: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

app/packages/state/src/recoil/utils.ts

[error] 145-155: The call chain .map().flat() can be replaced with a single .flatMap() call. (lint/complexity/useFlatMap)

Safe fix: Replace the chain with .flatMap().

app/packages/state/src/recoil/dynamicGroups.ts

[error] 238-238: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

app/packages/state/src/hooks/useCreateLooker.ts

[error] 81-81: Do not shadow the global "constructor" property. (lint/suspicious/noShadowRestrictedNames)

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.


[error] 241-241: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

Additional comments not posted (8)
app/packages/state/src/hooks/useHoveredSample.ts (2)

7-7: Refactoring to use object destructuring for function parameters enhances clarity and maintainability.


Line range hint 7-20: The logic for handling mouse events and managing hover state is correctly implemented.

Tools
Biome

[error] 12-12: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

app/packages/core/src/components/Modal/Sample.tsx (2)

44-44: The update to use the destructured hoverEventHandlers from useHoveredSample aligns with the new hook signature and improves code clarity.


44-62: Proper use of React hooks like useState, useRef, and useCallback ensures efficient state management and component re-rendering.

app/packages/state/src/hooks/useExpandSample.ts (1)

141-141: Direct usage of groupBy from dynamicGroupParameters simplifies the code and removes unnecessary abstraction layers.

app/packages/state/src/recoil/dynamicGroups.ts (1)

159-159: Consider using optional chaining for improved safety and readability.

- expr: `$${groupBy}`,
+ expr: `$${groupBy}?`,

Likely invalid or redundant comment.

app/packages/state/src/hooks/useCreateLooker.ts (2)

179-179: Implement optional chaining for safer access to properties.

- const groupByFieldValue = get(sample, groupBy);
+ const groupByFieldValue = get(sample, groupBy)?;

Likely invalid or redundant comment.


34-34: Ensure all necessary imports are present and correct given the removal of getSanitizedGroupByExpression.

Verification successful

The verification confirms that no other files are attempting to import the removed function getSanitizedGroupByExpression.

  • No occurrences of getSanitizedGroupByExpression were found in the TypeScript files.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that no other files are trying to import the removed function `getSanitizedGroupByExpression`.

# Test: Search for the function usage. Expect: No occurrences outside of already modified files.
rg --type typescript $'getSanitizedGroupByExpression'

Length of output: 87



Script:

#!/bin/bash
# Description: Verify that no other files are trying to import the removed function `getSanitizedGroupByExpression`.

# Test: Search for the function usage. Expect: No occurrences outside of already modified files.
rg --glob '*.ts' 'getSanitizedGroupByExpression'

Length of output: 48

app/packages/state/src/hooks/useHoveredSample.ts Outdated Show resolved Hide resolved
@benjaminpkane
Copy link
Contributor

Looks like e2e is failing

Copy link
Contributor

@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: 3

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 79a74a8 and 642272e.

Files selected for processing (1)
  • app/packages/state/src/hooks/useHoveredSample.ts (1 hunks)
Additional context used
Path-based instructions (1)
app/packages/state/src/hooks/useHoveredSample.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

Biome
app/packages/state/src/hooks/useHoveredSample.ts

[error] 12-12: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 16-16: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 20-20: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

Additional comments not posted (1)
app/packages/state/src/hooks/useHoveredSample.ts (1)

7-7: Refactor: Destructure function parameters for clarity.

The change to destructure update and clear functions in the function parameters enhances readability and makes the function usage more explicit.

Copy link
Contributor

@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: 3

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 642272e and 687745b.

Files selected for processing (1)
  • app/packages/state/src/hooks/useHoveredSample.ts (1 hunks)
Additional context used
Path-based instructions (1)
app/packages/state/src/hooks/useHoveredSample.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

Biome
app/packages/state/src/hooks/useHoveredSample.ts

[error] 12-12: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 16-16: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 20-20: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

}
function onMouseLeave() {
setSample(null);
clear && clear();
args?.clear && args.clear();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implement optional chaining for safety.

Similar to the previous comment, implement optional chaining for args.clear to prevent runtime errors when clear is undefined.

-    args?.clear && args.clear();
+    args?.clear?.();
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
args?.clear && args.clear();
args?.clear?.();
Tools
Biome

[error] 16-16: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

function onMouseEnter() {
setSample(sample);
update && update();
args?.update && args.update();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implement optional chaining for safety.

To ensure robustness, especially when args.update might be undefined, use optional chaining.

-    args?.update && args.update();
+    args?.update?.();
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
args?.update && args.update();
args?.update?.();
Tools
Biome

[error] 12-12: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

}
function onMouseMove() {
setSample(sample);
update && update();
args?.update && args.update();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistency in optional chaining.

For consistency and to avoid potential errors, apply optional chaining to args.update in the onMouseMove handler as well.

-    args?.update && args.update();
+    args?.update?.();
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
args?.update && args.update();
args?.update?.();
Tools
Biome

[error] 20-20: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

Copy link
Contributor

@benjaminpkane benjaminpkane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sashankaryal I think _sample_id needs to be added back. Or more generally, if the field has a db_field defined in its schema, it should use that. Happy to take offline

Dynamic video is working with the below on develop, but not on this branch.

import fiftyone.zoo

dataset = foz.load_zoo_dataset("quickstart-video")
frames = dataset.to_frames(sample_frames=True).clone("quickstart-frames")
video = frames.group_by("sample_id", order_by="frame_number")

session = fo.launch_app(video)

@sashankaryal sashankaryal force-pushed the bugfix/dynamic-groups-modal-keys branch from 687745b to 0bf5a77 Compare June 27, 2024 20:42
@sashankaryal sashankaryal force-pushed the bugfix/dynamic-groups-modal-keys branch from 0bf5a77 to aa34ca6 Compare June 27, 2024 20:44
@sashankaryal sashankaryal changed the title Fix dynamic groups modal shortcuts not working bug Fix dynamic groups modal shortcuts + dynamic groups refactoring to use schema Jun 27, 2024
Copy link
Contributor

@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: 1

Outside diff range and nitpick comments (2)
app/packages/state/src/hooks/useCreateLooker.ts (2)

Line range hint 82-82: Rename the constructor variable to avoid shadowing.

Using constructor as a variable name can lead to confusion due to its special meaning in JavaScript. Consider renaming it to something more specific like lookerConstructor.

- let constructor:
+ let lookerConstructor:

Line range hint 246-246: Use optional chaining for safer property access.

Implementing optional chaining here will prevent runtime errors if sample.group is undefined.

- if (sample.group.name) {
+ if (sample.group?.name) {
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 687745b and aa34ca6.

Files selected for processing (7)
  • app/packages/core/src/components/Modal/Sample.tsx (1 hunks)
  • app/packages/state/src/hooks/useCreateLooker.ts (3 hunks)
  • app/packages/state/src/hooks/useExpandSample.ts (3 hunks)
  • app/packages/state/src/hooks/useHoveredSample.ts (1 hunks)
  • app/packages/state/src/recoil/dynamicGroups.ts (4 hunks)
  • app/packages/state/src/recoil/utils.ts (1 hunks)
  • app/packages/utilities/src/schema.ts (2 hunks)
Files skipped from review as they are similar to previous changes (4)
  • app/packages/core/src/components/Modal/Sample.tsx
  • app/packages/state/src/hooks/useExpandSample.ts
  • app/packages/state/src/hooks/useHoveredSample.ts
  • app/packages/state/src/recoil/utils.ts
Additional context used
Path-based instructions (3)
app/packages/utilities/src/schema.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/state/src/recoil/dynamicGroups.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/state/src/hooks/useCreateLooker.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

Biome
app/packages/state/src/recoil/dynamicGroups.ts

[error] 242-242: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

app/packages/state/src/hooks/useCreateLooker.ts

[error] 82-82: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)


[error] 246-246: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Additional comments not posted (3)
app/packages/utilities/src/schema.ts (1)

4-4: Add documentation for pathWithDbField.

The new pathWithDbField property in the Field interface is a welcome addition for better handling of database fields. Consider adding documentation to explain its usage and significance.

app/packages/state/src/recoil/dynamicGroups.ts (1)

7-7: Check for potential impacts due to removal of getSanitizedGroupByExpression.

The removal of getSanitizedGroupByExpression and the addition of getFieldInfo are in line with the PR's objectives. However, ensure that all parts of the application that previously depended on the sanitized expressions are updated to work with the direct groupBy usage.

Verification successful

Check for potential impacts due to removal of getSanitizedGroupByExpression.

The removal of getSanitizedGroupByExpression and the addition of getFieldInfo are in line with the PR's objectives. The verification confirms that there are no remaining references to getSanitizedGroupByExpression in the codebase.

  • No further action is needed as the transition has been successfully completed.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all parts of the application have transitioned from `getSanitizedGroupByExpression` to `getFieldInfo`.

# Test: Search for any remaining references to `getSanitizedGroupByExpression`. Expect: None.
rg --type typescript $'getSanitizedGroupByExpression'

Length of output: 87



Script:

#!/bin/bash
# Description: Verify that all parts of the application have transitioned from `getSanitizedGroupByExpression` to `getFieldInfo`.

# Test: Search for any remaining references to `getSanitizedGroupByExpression`. Expect: None.
rg --type ts 'getSanitizedGroupByExpression'

Length of output: 44

app/packages/state/src/hooks/useCreateLooker.ts (1)

16-16: Ensure complete removal of dependencies on getSanitizedGroupByExpression.

The removal of getSanitizedGroupByExpression should simplify the logic. Ensure that no residual code depends on this function, potentially leading to errors.

Verification successful

Verified complete removal of getSanitizedGroupByExpression.

The search confirmed that there are no remaining references to getSanitizedGroupByExpression in the codebase, ensuring the logic simplification is fully implemented.

  • No further action required.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the complete removal of `getSanitizedGroupByExpression` and its dependencies.

# Test: Search for any remaining references to `getSanitizedGroupByExpression`. Expect: None.
rg --type typescript $'getSanitizedGroupByExpression'

Length of output: 87



Script:

#!/bin/bash
# Description: Verify the complete removal of `getSanitizedGroupByExpression` and its dependencies.

# Test: Search for any remaining references to `getSanitizedGroupByExpression`. Expect: None.
rg --type ts 'getSanitizedGroupByExpression'

Length of output: 44

app/packages/utilities/src/schema.ts Outdated Show resolved Hide resolved
@sashankaryal sashankaryal added the app Issues related to App features label Jul 2, 2024
Copy link
Contributor

@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: 1

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between aa34ca6 and 17fb19e.

Files selected for processing (2)
  • app/packages/utilities/src/schema.test.ts (3 hunks)
  • app/packages/utilities/src/schema.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/packages/utilities/src/schema.ts
Additional context used
Path-based instructions (1)
app/packages/utilities/src/schema.test.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

Additional comments not posted (2)
app/packages/utilities/src/schema.test.ts (2)

38-61: Ensure Consistency in Field Properties

The embeddedWithDbFields field is added correctly. However, ensure that all nested properties, such as dbField, pathWithDbField, and others, are consistently applied across similar fields in the schema.


84-87: Ensure Correctness of pathWithDbField Property

The test cases for getFieldInfo function are updated to include pathWithDbField. Verify that the expected values for pathWithDbField are correct and consistent with the schema's structure.

Also applies to: 91-94

Verification successful

Ensure Correctness of pathWithDbField Property

The test cases for the getFieldInfo function correctly reflect the assignment logic of pathWithDbField. The property is assigned by joining non-null dbField values, and the test cases expect pathWithDbField to be an empty string when no dbField values are present.

  • app/packages/utilities/src/schema.test.ts
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify correctness of `pathWithDbField` property in the schema.

# Test: Search for all occurrences of `pathWithDbField` in the schema file. Expect: Correct and consistent values.
rg --type json --json-path '$..pathWithDbField'

Length of output: 485



Script:

#!/bin/bash
# Description: Verify correctness of `pathWithDbField` property in the schema.

# Search for all occurrences of `pathWithDbField` in the codebase.
rg 'pathWithDbField'

Length of output: 949



Script:

#!/bin/bash
# Description: Extract and review the relevant code sections in `schema.ts` where `pathWithDbField` is assigned and used.

# Extract lines around the assignment of `pathWithDbField` in `schema.ts`.
rg -A 5 -B 5 'pathWithDbField' app/packages/utilities/src/schema.ts

Length of output: 540

Comment on lines 104 to 111
it("should return correct pathWithDbField", () => {
const field = schema.getFieldInfo(
"embeddedWithDbFields.sample_id",
SCHEMA
);
console.log("field is ", JSON.stringify(field, null, 2));
expect(field?.pathWithDbField).toBe("embeddedWithDbFields._sample_id");
});
Copy link
Contributor

@coderabbitai coderabbitai bot Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove Debugging Code

The console.log statement is used for debugging purposes and should be removed in the final code.

- console.log("field is ", JSON.stringify(field, null, 2));
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it("should return correct pathWithDbField", () => {
const field = schema.getFieldInfo(
"embeddedWithDbFields.sample_id",
SCHEMA
);
console.log("field is ", JSON.stringify(field, null, 2));
expect(field?.pathWithDbField).toBe("embeddedWithDbFields._sample_id");
});
it("should return correct pathWithDbField", () => {
const field = schema.getFieldInfo(
"embeddedWithDbFields.sample_id",
SCHEMA
);
expect(field?.pathWithDbField).toBe("embeddedWithDbFields._sample_id");
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sashankaryal I agree with 🐇 if you do

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Contributor

@benjaminpkane benjaminpkane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful! LGTM 🚀

Comment on lines 104 to 111
it("should return correct pathWithDbField", () => {
const field = schema.getFieldInfo(
"embeddedWithDbFields.sample_id",
SCHEMA
);
console.log("field is ", JSON.stringify(field, null, 2));
expect(field?.pathWithDbField).toBe("embeddedWithDbFields._sample_id");
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sashankaryal I agree with 🐇 if you do

Copy link
Contributor

@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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 17fb19e and 4bb2916.

Files selected for processing (1)
  • app/packages/utilities/src/schema.test.ts (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/packages/utilities/src/schema.test.ts

@sashankaryal sashankaryal merged commit d3e8293 into develop Jul 5, 2024
16 of 17 checks passed
@sashankaryal sashankaryal deleted the bugfix/dynamic-groups-modal-keys branch July 5, 2024 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app Issues related to App features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants