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

feat(hs): chunking data based on batch limit #2907

Merged
merged 29 commits into from
Feb 7, 2024
Merged

Conversation

mihir-4116
Copy link
Contributor

@mihir-4116 mihir-4116 commented Dec 13, 2023

What are the changes introduced in this PR?

Write a brief explainer on your code changes.

Please explain the objectives of your changes below

Put down any required details on the broader aspect of your changes. If there are any dependent changes, mandatorily mention them here

Type of change

If the pull request is a bug-fix, enhancement or a refactor, please fill in the details on the changes made.

  • Existing capabilities/behavior

  • New capabilities/behavior

If the pull request is a new feature,

Any technical or performance related pointers to consider with the change?

N/A

Any new dependencies introduced with this change?

N/A

Any new generic utility introduced or modified. Please explain the changes.

N/A

If the PR has changes in more than 10 files, please mention why the changes were not split into multiple PRs.

N/A

If multiple linear tasks are associated with the PR changes, please elaborate on the reason:

N/A


Developer checklist

  • No breaking changes are being introduced.

  • Are all related docs linked with the PR?

  • Are all changes manually tested?

  • Does this change require any documentation changes?

  • Are relevant unit and component test-cases added?

Reviewer checklist

  • Is the type of change in the PR title appropriate as per the changes?

  • Verified that there are no credentials or confidential data exposed with the changes.

Summary by CodeRabbit

  • New Features

    • Enhanced data handling with new utility functions for object and identifier validation, and unique value extraction.
    • Improved HubSpot search capabilities within the application.
  • Bug Fixes

    • Updated existing data retrieval function for better performance and accuracy.
  • Tests

    • Added test cases for new utility functions to ensure reliability and correctness.

@mihir-4116 mihir-4116 self-assigned this Dec 13, 2023
@mihir-4116 mihir-4116 requested a review from a team as a code owner December 13, 2023 09:15
Copy link
Contributor

coderabbitai bot commented Dec 13, 2023

Important

Auto Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.

Walkthrough

The recent updates introduce a new constant for handling the maximum number of contacts per request and expand utility functions in the HubSpot integration. These utilities include functions for object and identifier type validation, extracting unique values, and performing searches within HubSpot. Additionally, there are updates to existing functions to incorporate these new utilities, and corresponding tests have been added or modified to ensure functionality is as expected.

Changes

File Path Change Summary
src/v0/.../hs/config.js Added MAX_CONTACTS_PER_REQUEST constant and updated exports.
src/v0/.../hs/util.js Added functions for object and identifier validation, unique value extraction, and HubSpot search; updated getExistingData function; added MAX_CONTACTS_PER_REQUEST constant; disabled no-await-in-loop eslint rule.
src/v0/.../hs/util.test.js Added tests for new utility functions extractUniqueValues, getObjectAndIdentifierType; updated validatePayloadDataTypes test cases.

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-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@mihir-4116 mihir-4116 changed the title feat(hs): chunking data based on batch limit feat(INT-915): chunking data based on batch limit Dec 13, 2023
@mihir-4116 mihir-4116 changed the title feat(INT-915): chunking data based on batch limit feat(hs): chunking data based on batch limit Dec 13, 2023
Copy link

codecov bot commented Dec 13, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (2a21274) 87.26% compared to head (90f3784) 87.27%.

Files Patch % Lines
src/v0/destinations/hs/util.js 98.11% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2907   +/-   ##
========================================
  Coverage    87.26%   87.27%           
========================================
  Files          534      534           
  Lines        29055    29069   +14     
  Branches      6918     6917    -1     
========================================
+ Hits         25355    25370   +15     
+ Misses        3358     3357    -1     
  Partials       342      342           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mihir-4116 mihir-4116 requested a review from utsabc December 13, 2023 12:31
@utsabc
Copy link
Member

utsabc commented Dec 27, 2023

Can we add unit tests for the utils.js

@koladilip
Copy link
Contributor

@coderabbitai review

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between f16066c and 181d0b1.
Files selected for processing (3)
  • src/v0/destinations/hs/config.js (2 hunks)
  • src/v0/destinations/hs/util.js (6 hunks)
  • src/v0/destinations/hs/util.test.js (2 hunks)
Additional comments: 11
src/v0/destinations/hs/config.js (2)
  • 67-68: The addition of MAX_CONTACTS_PER_REQUEST constant is consistent with the PR's objective to implement data chunking based on a batch limit.
  • 114-114: Ensure that the new constant MAX_CONTACTS_PER_REQUEST is being used wherever applicable to enforce the batch limit.
Verification successful

I have verified the usage of the MAX_CONTACTS_PER_REQUEST constant in the codebase. It is being used in the config.js file where it is defined, and also in the util.js file where it is utilized to chunk values. Based on this verification, it seems that the new constant is being used correctly to enforce the batch limit as intended.

Conclusion

The usage of the MAX_CONTACTS_PER_REQUEST constant has been verified and found to be consistent with the expected usage. Therefore, the review comment has been successfully addressed.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for usage of MAX_CONTACTS_PER_REQUEST in the codebase to ensure it's being used correctly.
rg 'MAX_CONTACTS_PER_REQUEST' --type js

Length of output: 331

src/v0/destinations/hs/util.test.js (3)
  • 1-5: The import changes reflect the addition of new utility functions and are consistent with the changes in util.js.
  • 48-110: The tests for getObjectAndIdentifierType function are well-structured and cover both positive and negative scenarios.
  • 112-202: The tests for extractUniqueValues function are comprehensive and check for both non-empty and empty input scenarios.
src/v0/destinations/hs/util.js (6)
  • 1-1: Disabling the no-await-in-loop eslint rule is justified in this context as the loop contains asynchronous calls that depend on the result of the previous iteration.
  • 474-483: The getObjectAndIdentifierType function correctly extracts the objectType and identifierType from the message and throws an error if they are not found.
  • 490-498: The extractUniqueValues function correctly extracts and deduplicates values from the input array.
  • 536-625: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [509-568]

The performHubSpotSearch function implements pagination correctly and accumulates results from potentially multiple API calls. Ensure that the batch size and pagination are handled correctly to avoid rate limits and performance issues.

  • 575-621: The getExistingData function uses the new utility functions to perform its task. Ensure that the chunking of values (lodash.chunk) respects the MAX_CONTACTS_PER_REQUEST and that the error handling is robust.
  • 734-735: Exporting the new utility functions aligns with the changes made in the test file and the overall PR objectives.

src/v0/destinations/hs/util.js Outdated Show resolved Hide resolved
src/v0/destinations/hs/util.js Outdated Show resolved Hide resolved
src/v0/destinations/hs/util.js Outdated Show resolved Hide resolved
src/v0/destinations/hs/util.js Outdated Show resolved Hide resolved
@mihir-4116 mihir-4116 requested a review from koladilip January 24, 2024 05:33
@devops-github-rudderstack
Copy link
Contributor

1 similar comment
@devops-github-rudderstack
Copy link
Contributor

@devops-github-rudderstack
Copy link
Contributor

@devops-github-rudderstack
Copy link
Contributor

utsabc
utsabc previously approved these changes Feb 7, 2024
src/v0/destinations/hs/util.js Show resolved Hide resolved
src/v0/destinations/hs/util.js Outdated Show resolved Hide resolved
@devops-github-rudderstack
Copy link
Contributor

utsabc
utsabc previously approved these changes Feb 7, 2024
@devops-github-rudderstack
Copy link
Contributor

koladilip
koladilip previously approved these changes Feb 7, 2024
koladilip
koladilip previously approved these changes Feb 7, 2024
@devops-github-rudderstack
Copy link
Contributor

@devops-github-rudderstack
Copy link
Contributor

Copy link

sonarqubecloud bot commented Feb 7, 2024

@mihir-4116 mihir-4116 merged commit a60694c into develop Feb 7, 2024
14 checks passed
@mihir-4116 mihir-4116 deleted the feat.hs-batching branch February 7, 2024 05:13
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.

4 participants