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: mongo schema collections order of mongo plugin #36062

Merged

Conversation

raushan3737
Copy link
Contributor

@raushan3737 raushan3737 commented Sep 3, 2024

PR Description:

  • File changes in the PR:
    • Integrated the sorting feature to the mongo collections.
    • Added the unit test for sorting.

Fixes #35842

  • Snapshots:

    Before resolving bug:

    image

    After resolving bug:

    image

Summary by CodeRabbit

  • New Features

    • Enhanced the MongoDB plugin to return collection names in a case-insensitive sorted order, improving predictability and user experience.
  • Tests

    • Added a new test to validate that collections returned by the plugin are sorted correctly, ensuring consistent functionality.

Copy link
Contributor

coderabbitai bot commented Sep 3, 2024

Walkthrough

The changes involve modifications to the getStructure method in the MongoPlugin class to ensure that MongoDB collection names are returned in a case-insensitive sorted order. Additionally, a new test method has been added to verify that the collections are indeed sorted correctly, enhancing the reliability of the plugin's functionality.

Changes

File Change Summary
app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/MongoPlugin.java Modified getStructure method to sort collection names in a case-insensitive manner.
app/server/appsmith-plugins/mongoPlugin/src/test/java/com/external/plugins/MongoPluginQueriesTest.java Added testStructure_should_return_collections_in_order to verify sorted order of collections.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MongoPlugin
    participant Database

    User->>MongoPlugin: Request collection structure
    MongoPlugin->>Database: Fetch collection names
    Database-->>MongoPlugin: Return collection names
    MongoPlugin->>MongoPlugin: Sort collection names (case-insensitive)
    MongoPlugin-->>User: Return sorted collection names
Loading

Assessment against linked issues

Objective Addressed Explanation
Collections are sorted in schemas (Issue #35842)

Poem

In the realm of Mongo, collections align,
With names now sorted, oh how they shine!
From chaos to order, a tidy display,
A plugin enhancement, brightening the day!
Let's celebrate coding, with joy in our heart,
For every small change is a beautiful art! 🎉


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 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 resolve resolve all the CodeRabbit review comments.
  • @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.

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.
Early access features: disabled

We are currently testing the following features in early access:

  • Anthropic claude-3-5-sonnet for code reviews: Anthropic claims that the new Claude model has stronger code understanding and code generation capabilities than their previous models. Note: Our default code review model was also updated late last week. Please compare the quality of the reviews between the two models by toggling the early access feature.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues on the discussion post.

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 4516129 and 42a1c8e.

Files selected for processing (2)
  • app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/MongoPlugin.java (1 hunks)
  • app/server/appsmith-plugins/mongoPlugin/src/test/java/com/external/plugins/MongoPluginQueriesTest.java (1 hunks)
Additional comments not posted (2)
app/server/appsmith-plugins/mongoPlugin/src/test/java/com/external/plugins/MongoPluginQueriesTest.java (1)

659-676: Great job adding this new test method!

The testStructure_should_return_collections_in_order method is a valuable addition to the test suite. It verifies that the getStructure method returns the MongoDB collections in the correct ascending order.

The test follows these steps:

  1. Creates a DatasourceConfiguration.
  2. Invokes the datasourceCreate method.
  3. Calls the getStructure method.
  4. Uses StepVerifier to make assertions on the resulting Mono<DatasourceStructure>:
    • Checks that the structure is not null.
    • Verifies that it contains exactly three tables.
    • Asserts that the tables are sorted correctly by name: "address", "teams", and "users".

This test enhances the reliability of the plugin's functionality by ensuring that the collections are always returned in a predictable sorted order.

Keep up the great work in improving the test coverage and validating the expected behavior! 👍

app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/MongoPlugin.java (1)

915-915: Excellent work on sorting the collection names! This enhances the user experience.

By sorting the collection names using compareToIgnoreCase, you ensure that the output is consistently ordered regardless of the case. This provides a more predictable and user-friendly result.

The subsequent logic remains unaffected, but the introduction of sorting improves the overall behavior of the method.

@raushan3737
Copy link
Contributor Author

Hi @NilanshBansal, @sagar-qa007, Could you please review this PR.
Thank you.

@NilanshBansal NilanshBansal requested a review from a team September 6, 2024 07:15
@NilanshBansal NilanshBansal added Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Community Contributor Meant to track issues that are assigned to external contributors Integrations Pod labels Sep 6, 2024
Copy link

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Sep 13, 2024
@NilanshBansal NilanshBansal requested review from NilanshBansal and removed request for a team September 19, 2024 05:41
@NilanshBansal NilanshBansal self-assigned this Sep 19, 2024
@raushan3737
Copy link
Contributor Author

Hi @NilanshBansal , Could you please review the PR if possible. It has been opened since last 3 weeks.

@NilanshBansal
Copy link
Contributor

Hey @raushan3737 apologies for the inconvenience, we are starting to review this PR and targeting to complete it by Next Friday.

@NilanshBansal
Copy link
Contributor

Hi @raushan3737 thanks for your patience. We have created shadow PR here to run the tests.

@NilanshBansal
Copy link
Contributor

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11029317630.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 36062.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-36062.dp.appsmith.com

@NilanshBansal
Copy link
Contributor

Tested the DP, it looks good to me.
image

@nerbos nerbos merged commit cdb22f4 into appsmithorg:release Sep 25, 2024
25 of 26 checks passed
@NilanshBansal
Copy link
Contributor

@raushan3737 thanks for taking out time to contribute to Appsmith! We highly appreciate your effort in making Appsmith better ❤️
You can find more issues to contribute from this list!

Shivam-z pushed a commit to Shivam-z/appsmith that referenced this pull request Sep 26, 2024
### PR Description: 
- **File changes in the PR**:
  - Integrated the sorting feature to the mongo collections.
  - Added the unit test for sorting.

Fixes appsmithorg#35842

- **Snapshots**:
  
  **Before resolving bug:**
  

![image](https://github.com/user-attachments/assets/34c04ebc-e81b-480c-9a54-1b643b68ffb2)
  
  **After resolving bug:**
  

![image](https://github.com/user-attachments/assets/fd7155e1-e261-491a-b912-7d482b8a9386)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Enhanced the MongoDB plugin to return collection names in a
case-insensitive sorted order, improving predictability and user
experience.
  
- **Tests**
- Added a new test to validate that collections returned by the plugin
are sorted correctly, ensuring consistent functionality.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contributor Meant to track issues that are assigned to external contributors Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Integrations Pod
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Mongodb collections are not in sorted order in schemas.
3 participants