feat: apply QuantityMultiplier for server-side vendor offers #605
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "servervendors"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #572
Walkthrough
The pull request introduces a comprehensive refactoring of vendor information retrieval and purchase handling across multiple files. The changes primarily focus on creating a centralized approach to managing vendor manifests through the new
serversideVendorsService.ts
file.The
getVendorInfoController.ts
was modified to simplify vendor manifest retrieval by replacing a complexswitch
statement with a single function callgetVendorManifestByTypeName()
. This new approach reduces code complexity and improves maintainability.In
purchaseService.ts
, thehandlePurchase
function was enhanced to incorporate additional logic for handling vendor-specific purchases. A new conditional check was added to handle purchases from source 7, which now retrieves vendor manifests using the source ID and adjusts purchase quantities based on offer multipliers.The newly created
serversideVendorsService.ts
serves as the core of these changes, introducing anIVendorManifest
interface and two key functions:getVendorManifestByTypeName()
andgetVendorManifestByOid()
. These functions provide a standardized method for retrieving vendor manifest information based on type name or object ID.Assessment against linked issues
The changes directly address the requirements in issue #572 by implementing a mechanism to retrieve and apply vendor-specific purchase details, particularly for purchases with source 7. The new
serversideVendorsService.ts
and modifications topurchaseService.ts
enable dynamic quantity adjustments based on vendor manifests, resolving the original issue of incorrect item quantities.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:
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.
@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.
@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
@coderabbitai ignore
anywhere in the PR description to prevent this PR from being reviewed.@coderabbitai summary
to generate the high-level summary at a specific location in the PR description.@coderabbitai
anywhere in the PR title to generate the title automatically.Documentation and Community
Actionable comments posted: 0
🧹 Nitpick comments (3)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
0a31ff7b5c
and 3df32060d54f1ec05e0b88aba56391e1c5f02762.📒 Files selected for processing (3)
src/controllers/api/getVendorInfoController.ts
(1 hunks)src/services/purchaseService.ts
(3 hunks)src/services/serversideVendorsService.ts
(1 hunks)🧰 Additional context used
🪛 GitHub Check: build (22)
src/services/purchaseService.ts
[failure] 72-72:
This assertion is unnecessary since it does not change the type of the expression
[failure] 73-73:
This assertion is unnecessary since it does not change the type of the expression
🪛 GitHub Check: build (20)
src/services/purchaseService.ts
[failure] 72-72:
This assertion is unnecessary since it does not change the type of the expression
[failure] 73-73:
This assertion is unnecessary since it does not change the type of the expression
🪛 GitHub Check: build (18)
src/services/purchaseService.ts
[failure] 72-72:
This assertion is unnecessary since it does not change the type of the expression
[failure] 73-73:
This assertion is unnecessary since it does not change the type of the expression
🔇 Additional comments (3)
src/controllers/api/getVendorInfoController.ts (1)
12-12
: Confirm multiple vendor query values scenario is handled.When the query parameter is not a single string (for instance, if vendor query param is repeated in the URL), the code produces a 400 response. Ensure this is the intended behavior and that any multi-value vendor query scenarios are not needed.
src/services/serversideVendorsService.ts (1)
30-40
: Validate vendor data for missing or malformed fields.The IVendorManifest interface outlines a “QuantityMultiplier” field. Ensure that each imported JSON manifest has valid data (particularly around numeric values) to avoid runtime issues or NaN errors.
src/services/purchaseService.ts (1)
36-46
: Ensure vendor-based quantity multiplier logic is correct.Multiplying the requested purchase quantity (line 43) by the vendor’s QuantityMultiplier is appropriate for scaling the user request. However, confirm that negative or zero multipliers are not possible, and ensure the product remains within permissible bounds to avoid partial, negative, or excessively large purchase quantities.