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

Use the new batch endpoint in MM #2910

Merged
merged 3 commits into from
Dec 29, 2024
Merged

Use the new batch endpoint in MM #2910

merged 3 commits into from
Dec 29, 2024

Conversation

MatanYadaev
Copy link
Collaborator

@MatanYadaev MatanYadaev commented Dec 26, 2024

Summary by CodeRabbit

  • New Features
    • Enhanced URL validation to support a broader range of valid URLs, including localhost and specific port numbers.
    • New transformation for websiteUrl to ensure it is stored in lowercase.
  • Bug Fixes
    • Reduced maximum allowable batch size for business report requests from 10,000 to 1,000.
  • Chores
    • Updated subproject commit reference to the latest version.
    • Removed unnecessary type definitions and schemas to streamline data handling.

- Update URL regex pattern for improved validation
- Adjust maximum batch size from 10,000 to 1,000 for better manageability
- Streamline report request transformation for clarity

(your batch size restriction feels like a diet plan that only allows rabbit food)
Copy link

changeset-bot bot commented Dec 26, 2024

⚠️ No Changeset found

Latest commit: 52733a9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Dec 26, 2024

Walkthrough

This pull request introduces several modifications across multiple services and files, primarily focusing on URL validation, business report processing, and data handling. The changes include updating the URL regex pattern, reducing the batch size for business report requests, transforming website URLs to lowercase, and refactoring the merchant monitoring client's batch creation method. The modifications aim to improve data consistency, validation, and processing efficiency in the workflows service.

Changes

File Change Summary
packages/common/src/consts/index.ts Updated URL_PATTERN regex for more comprehensive URL validation
services/workflows-service/prisma/data-migrations Updated subproject commit hash
services/workflows-service/src/business-report/business-report.service.ts Reduced max batch size from 10,000 to 1,000 reports, modified createBatch method data structure
services/workflows-service/src/business-report/dtos/create-business-report.dto.ts Added @Transform decorator to convert websiteUrl to lowercase
services/workflows-service/src/business-report/merchant-monitoring-client.ts Refactored createBatch method parameters and implementation
services/workflows-service/src/common/schemas.ts Added lowercase transformation to websiteUrl in BusinessReportRequestSchema
services/workflows-service/src/common/utils/unified-api-client/unified-api-client.ts Removed TReportRequest type definition

Possibly Related PRs

Suggested Reviewers

  • tomer-shvadron

Poem

🐰 A rabbit's tale of code so bright,
URL patterns now shine with might!
Batch sizes trimmed, lowercase delight,
Transforming data with technical flair,
Our workflows dance without a care! 🚀

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

CodeRabbit Configuration 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.

packages/common/src/consts/index.ts Dismissed Show dismissed Hide dismissed
packages/common/src/consts/index.ts Dismissed Show dismissed Hide dismissed
packages/common/src/consts/index.ts Dismissed Show dismissed Hide dismissed
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

🧹 Nitpick comments (3)
services/workflows-service/src/business-report/merchant-monitoring-client.ts (1)

135-148: Consider returning or inspecting the response for better error handling

Currently, this function silently returns void after the HTTP request. If the remote service responds with partial success or additional data, it is not accessible. For robust error handling or logging, consider returning the response or at least confirming a successful result.

  public async createBatch({...}) {
    const response = await this.axios.post(...);
+   return response.data; // or parse/validate if needed
  }
services/workflows-service/src/business-report/dtos/create-business-report.dto.ts (1)

Line range hint 11-30: Consistent URL transformation with the schema

Using a @Transform decorator aligns with the schema’s .transform(value => value.toLowerCase()). Double-check whether lowercasing is desired for the entire URL, as some servers differentiate path case.

packages/common/src/consts/index.ts (1)

172-172: Consider using a standard library for complex URL parsing

The updated regex covers many cases but may not handle all IDNs or punycode domains, and can be challenging to maintain. Consider using the built-in URL constructor or a dedicated library for robust URL validation.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 01c1a6c and 034e041.

📒 Files selected for processing (7)
  • packages/common/src/consts/index.ts (1 hunks)
  • services/workflows-service/prisma/data-migrations (1 hunks)
  • services/workflows-service/src/business-report/business-report.service.ts (2 hunks)
  • services/workflows-service/src/business-report/dtos/create-business-report.dto.ts (2 hunks)
  • services/workflows-service/src/business-report/merchant-monitoring-client.ts (1 hunks)
  • services/workflows-service/src/common/schemas.ts (1 hunks)
  • services/workflows-service/src/common/utils/unified-api-client/unified-api-client.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • services/workflows-service/src/common/utils/unified-api-client/unified-api-client.ts
✅ Files skipped from review due to trivial changes (1)
  • services/workflows-service/prisma/data-migrations
🔇 Additional comments (4)
services/workflows-service/src/business-report/merchant-monitoring-client.ts (1)

117-133: Validate optional workflowVersion parameter or provide a default

The updated parameters for createBatch allow workflowVersion to be optional, but there is no explicit validation or fallback default, which might cause unexpected behavior if the caller omits it.

Would you like to define a reasonable default value or enforce validation to ensure consistency?

services/workflows-service/src/common/schemas.ts (1)

21-24: Confirm that forcing all URLs to lowercase supports all use cases

Lowercasing the entire URL standardizes domains but can break path-based resources if the path is case-sensitive. If case handling is only critical for the domain, consider parsing to selectively lowercase the domain component while preserving the path.

services/workflows-service/src/business-report/business-report.service.ts (2)

124-125: Revisiting the batch-size limit

Reducing the batch size to 1,000 helps avoid large payload issues. If larger batches become necessary, consider chunking or streaming to avoid potential timeouts.


163-173: Ensure correlation data is passed when needed

The new createBatch call correctly uses the updated signature. However, note that only businessId is appended to callbackUrl; if correlation or other identifiers are also needed downstream, consider adding them to the URL.

@MatanYadaev MatanYadaev changed the title Use the new batch endpoint in the WF service Use the new batch endpoint in MM Dec 26, 2024
@MatanYadaev MatanYadaev enabled auto-merge (squash) December 29, 2024 12:39
@MatanYadaev MatanYadaev merged commit e56b926 into dev Dec 29, 2024
10 checks passed
@MatanYadaev MatanYadaev deleted the bal-3244 branch December 29, 2024 12:48
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