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:added a method to identify the data types properly and show in th… #35394

Open
wants to merge 4 commits into
base: release
Choose a base branch
from

Conversation

Naveen-Goud
Copy link
Contributor

@Naveen-Goud Naveen-Goud commented Aug 5, 2024

Description of PR

  • this pr contains the changes to handle the data types from the user regarding feature

Changes in PR

  • In this PR added a method ,which takes the json data and it identifies the datatypes, then saves in firestore as expected.

fixes- #7176

output

  • below are the screen shots , after sending the data, they are stored in firestore with proper datatype format.
    Screenshot from 2024-05-31 16-26-01
    Screenshot from 2024-05-31 16-26-52
    Screenshot from 2024-05-31 16-27-06

below is the screen shot, when we try to get the documents then they are also represented based on their format
Screenshot from 2024-05-31 16-28-26

Summary by CodeRabbit

  • New Features

    • Enhanced data handling capabilities for geolocation and timestamp data in the Firestore integration.
    • Improved validation for Firestore document references.
    • Added robust data conversion methods for better formatting of Firestore data.
  • Bug Fixes

    • Fixed issues related to incorrect formatting of timestamp and geolocation data.
  • Tests

    • Introduced a new test suite for validating the functionality of the Firestore plugin against an emulated Firestore environment.

Copy link
Contributor

coderabbitai bot commented Aug 5, 2024

Walkthrough

The updates to the FirestorePlugin class significantly enhance its functionality, specifically in handling geolocation and timestamp data. New constants and a regex pattern improve data validation, while modifications to the methodAddToCollection and resultToMap methods ensure accurate data conversion and formatting. These changes facilitate better integration with Firestore, leading to more consistent and usable data within the application.

Changes

File Path Change Summary
app/server/appsmith-plugins/firestorePlugin/src/main/java/com/external/plugins/FirestorePlugin.java - Added constants for geolocation (LATITUDE, LONGITUDE) and Firestore timestamps (SECONDS, NANO_SECONDS).
- Introduced REFERENCE_PATTERN for validation.
- Updated methodAddToCollection for improved handling of geolocation and timestamps via checkAndConvertDataType.
- Enhanced resultToMap for better formatting of Timestamp and GeoPoint.
app/server/appsmith-plugins/firestorePlugin/src/test/java/com/external/plugins/FirestorePluginExecutorTest.java - Introduced a test suite for FirestorePluginExecutor using JUnit and Testcontainers.
- Implemented testMethodAddToCollection to validate document addition and data types in Firestore.

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>, 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 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.

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 UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7adb33d and 7ff6d42.

Files selected for processing (1)
  • app/server/appsmith-plugins/firestorePlugin/src/main/java/com/external/plugins/FirestorePlugin.java (10 hunks)
Additional comments not posted (5)
app/server/appsmith-plugins/firestorePlugin/src/main/java/com/external/plugins/FirestorePlugin.java (5)

93-98: LGTM! Verify the usage of new constants and regex pattern.

The new constants and regex pattern are well-defined.

Ensure that these new constants and the regex pattern are correctly used throughout the codebase.

Verification successful

Usage of new constants and regex pattern verified.

The new constants (LATITUDE, LONGITUDE, SECONDS, NANO_SECONDS) and the regex pattern (REFERENCE_PATTERN) are appropriately used in the FirestorePlugin.java file.

  • File: app/server/appsmith-plugins/firestorePlugin/src/main/java/com/external/plugins/FirestorePlugin.java
    • Lines:
      • REFERENCE_PATTERN: Line 93, 98
      • LATITUDE: Line 94, 99, 100
      • LONGITUDE: Line 95, 101, 102
      • SECONDS: Line 96, 97, 99
      • NANO_SECONDS: Line 97, 98, 100
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of new constants and regex pattern in the codebase.

# Test: Search for the usage of each constant and the regex pattern. Expect: Appropriate usage in relevant methods.
rg --type java 'LATITUDE|LONGITUDE|SECONDS|NANO_SECONDS|REFERENCE_PATTERN'

Length of output: 11984


809-811: LGTM! Verify the correctness of checkAndConvertDataType method.

The checkAndConvertDataType method is correctly applied to mapBody.

Ensure that the checkAndConvertDataType method is functioning as expected.

Verification successful

Verified: The checkAndConvertDataType method is correctly implemented and applied.

The method handles various data types and converts them appropriately, ensuring the correct data types are used within the Firestore plugin.

  • Converts specific map structures to Timestamp and GeoPoint objects.
  • Validates and processes strings as Firestore document references.
  • Returns the original value for other types.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `checkAndConvertDataType` method.

# Test: Search for the implementation and usage of `checkAndConvertDataType` method. Expect: Correct implementation and usage.
rg --type java 'checkAndConvertDataType'

Length of output: 427


Script:

#!/bin/bash
# Extract the implementation details of the `checkAndConvertDataType` method from FirestorePlugin.java
ast-grep --lang java --pattern $'private Object checkAndConvertDataType(Object value, CollectionReference collection) {
  $$$
}' 

Length of output: 3925


836-858: LGTM! Verify the correctness of checkAndConvertDataType method.

The checkAndConvertDataType method correctly identifies and converts timestamp and geolocation data types.

Ensure that the method handles all edge cases and functions as expected.

Verification successful

Verification Successful: checkAndConvertDataType Method

The checkAndConvertDataType method is correctly implemented and used within the FirestorePlugin.java file. It ensures that specific data types are converted to Firestore-compatible types before the data is used in Firestore operations.

  • The method is invoked in a replaceAll call on the mapBody variable, which is a Map<String, Object>.
  • The method handles timestamp and geolocation data types, converting them to Firestore's Timestamp and GeoPoint types, respectively.
  • The usage context confirms that the method is applied correctly to transform data before Firestore operations.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `checkAndConvertDataType` method.

# Test: Search for the implementation and usage of `checkAndConvertDataType` method. Expect: Correct implementation and usage.
rg --type java 'checkAndConvertDataType'

Length of output: 427


Script:

#!/bin/bash
# Extract more context around the usage of `checkAndConvertDataType` method in `FirestorePlugin.java`.

# Search for the `mapBody` variable and its surrounding code.
rg --type java -A 10 'mapBody' app/server/appsmith-plugins/firestorePlugin/src/main/java/com/external/plugins/FirestorePlugin.java

Length of output: 7936


504-504: LGTM! Verify the correctness of handleDocumentLevelMethod method.

The handleDocumentLevelMethod method includes changes to handle the new data types.

Ensure that the method handles all edge cases and functions as expected.


911-920: LGTM! Verify the correctness of resultToMap method.

The resultToMap method correctly handles Timestamp and GeoPoint types.

Ensure that the method handles all edge cases and functions as expected.

@@ -829,6 +833,30 @@ private Mono<ActionExecutionResult> methodAddToCollection(
});
}

private Object checkAndConvertDataType(Object value, CollectionReference collection) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@Naveen-Goud Please add unit test case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hii @sagar-qa007 ,I have added the test case for this scenario. Please can you go through it.

@Naveen-Goud Naveen-Goud requested a review from sagar-qa007 August 7, 2024 07:03
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 UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7ff6d42 and 72b6df8.

Files selected for processing (1)
  • app/server/appsmith-plugins/firestorePlugin/src/test/java/com/external/plugins/FirestorePluginExecutorTest.java (1 hunks)
Additional comments not posted (5)
app/server/appsmith-plugins/firestorePlugin/src/test/java/com/external/plugins/FirestorePluginExecutorTest.java (5)

1-24: Imports are appropriate.

The imports include necessary libraries for Firestore, testing, and reactive programming. No unused imports are detected.


26-29: Class declaration is appropriate.

The class is annotated with @Testcontainers and contains a FirestorePluginExecutor instance.


31-35: Firestore emulator setup is correct.

The Firestore emulator is correctly set up using FirestoreEmulatorContainer.


39-50: setUp method is correct.

The setUp method correctly initializes the Firestore connection and sets the datasource configuration.


52-83: Test method testMethodAddToCollection is comprehensive.

The test method correctly tests the addition of a document to a Firestore collection and validates the data types.

@NilanshBansal NilanshBansal requested a review from a team August 10, 2024 12:06
@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 labels Aug 10, 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 Aug 19, 2024
sagar-qa007
sagar-qa007 previously approved these changes Aug 20, 2024
@Naveen-Goud
Copy link
Contributor Author

Hii @somangshu @NilanshBansal @Nikhil-Nandagopal , this PR has been approved , can you merge the changes !!

thank you.

@NilanshBansal
Copy link
Contributor

@Naveen-Goud this needs further testing from our end. We will be prioritising this in the next week.
cc: @rohan-arthur @carinanfonseca

@github-actions github-actions bot removed the Stale label Aug 22, 2024
@rishabhrathod01 rishabhrathod01 requested review from rishabhrathod01 and removed request for a team August 28, 2024 08:23
Copy link

github-actions bot commented Sep 4, 2024

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

@Naveen-Goud
Copy link
Contributor Author

Hi @rishabhrathod01, I have resolved the comments.Can you review the updated code.
thank you.

@rishabhrathod01
Copy link
Contributor

@Naveen-Goud the server unit test is failing for above PR, could you please check.

@Naveen-Goud
Copy link
Contributor Author

Naveen-Goud commented Sep 8, 2024

Hii @rishabhrathod01 , I have updated the test files and removed few statement in FirestorePluginTest, since they are covered in test file firestorePluginExecutorTest which contains the test cases that I have written.

thank you.

@rishabhrathod01
Copy link
Contributor

@Naveen-Goud could you please resolve the merge conflict by taking pull from latest release?

@Naveen-Goud Naveen-Goud force-pushed the fix/7176-Firestore_DB_needs_additional_API_support_to_ingest_certain_data_types branch from 8a1ca32 to d5297ca Compare September 20, 2024 05:33
@Naveen-Goud
Copy link
Contributor Author

Hii @rishabhrathod01 , I have resolved the merge conficts , could you review this PR.

thank you.

@rishabhrathod01 rishabhrathod01 removed their request for review September 26, 2024 11:00
@rishabhrathod01
Copy link
Contributor

rishabhrathod01 commented Sep 26, 2024

@Naveen-Goud there are server unit tests that are failing on the PR, could you please resolve them?

cc: @NilanshBansal I have unassigned myself here from the reviewer, we could re-assign the reviewer to this PR.

@Naveen-Goud
Copy link
Contributor Author

Hi @NilanshBansal ,I have checked the test case failing files, those files are not related to the changes I have made.

thank you.

@NilanshBansal NilanshBansal added Query & JS Pod Issues related to the query & JS Pod Integrations Pod labels Oct 1, 2024
@NilanshBansal NilanshBansal removed the request for review from a team December 27, 2024 05:29
Copy link

github-actions bot commented Feb 4, 2025

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 Feb 4, 2025
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 Query & JS Pod Issues related to the query & JS Pod Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants