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

WD-16445 Pick product listings with the right financial quarter #14554

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

minkyngkm
Copy link
Contributor

@minkyngkm minkyngkm commented Dec 10, 2024

Done

  • Pick product listings with the right financial quarter
  • How it should work: there are product listings from the backend. When a user selects an offer, only the product listings matching the offer's exclusion group should be available in the shop. For example, product listings with different exclusion groups may exist for the same products such as 2024-Q1 or 2024-quarter-2 (names can be any string). If an offer's exclusion group is 2024-Q4, only product listings with 2024-Q4 should be available.

QA

  • Check out this feature branch or demo
  • Go to /pro/distributor
  • Select offer
  • Check adding/removing subscriptions in the step 4 on the shop are working properly and check the summary at the bottom changes correctly
  • Check everything working fine on the shop page
  • Click "Proceed to checkout" to go to the checkout page
  • Update info if necessary
  • Check making a purchase works as expected.

Issue / Card

Fixes #https://warthogs.atlassian.net/browse/WD-16445

@webteam-app
Copy link

Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 22.68041% with 75 lines in your changes missing coverage. Please review.

Project coverage is 69.97%. Comparing base (5e948fa) to head (100b756).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
...js/src/advantage/distributor/utils/FormContext.tsx 0.00% 49 Missing ⚠️
static/js/src/advantage/distributor/utils/utils.ts 40.90% 26 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14554      +/-   ##
==========================================
+ Coverage   69.64%   69.97%   +0.33%     
==========================================
  Files         120      120              
  Lines        3419     3387      -32     
  Branches     1174     1166       -8     
==========================================
- Hits         2381     2370      -11     
+ Misses       1013      992      -21     
  Partials       25       25              
Files with missing lines Coverage Δ
...js/src/advantage/offers/components/Offer/Offer.tsx 100.00% <100.00%> (ø)
.../advantage/offers/tests/factories/channelOffers.ts 100.00% <100.00%> (ø)
.../js/src/advantage/offers/tests/factories/offers.ts 100.00% <100.00%> (ø)
...c/advantage/subscribe/checkout/utils/test/Mocks.ts 100.00% <ø> (ø)
static/js/src/advantage/distributor/utils/utils.ts 46.98% <40.90%> (-7.36%) ⬇️
...js/src/advantage/distributor/utils/FormContext.tsx 3.48% <0.00%> (+0.73%) ⬆️

@@ -70,7 +70,7 @@ export type ChannelProduct = {
productID: ValidProductID;
productName: string;
marketplace: UserSubscriptionMarketplace;
version: string;
exclusion_group: string;

Choose a reason for hiding this comment

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

not sure if this is relevant here, but the exclusion group might be missing (which is the same as it being an empty string) in product listings just like it can be missing in offers. does that perhaps mean that this should be exclusion_group?: string;, just like in the Offer type?

Copy link
Contributor Author

@minkyngkm minkyngkm Dec 16, 2024

Choose a reason for hiding this comment

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

For offer types, I considered both normal offers and channel offers. so the exclusion group should be optional for offers type, but for channel offers, I made the exclusion group to always return "" if it doesn't exist. This also applies to product listings for channel offers, so if an offer's exclusion group is "" (doesn't exist), it can fetch product listings with exclusion group of ""

listing?.metadata?.find((data: Metadata) => data.key === "version")
?.value || "1"; // "2"
return { nameWithoutVersion, version }; // ex: { nameWithoutVersion: "uai-essential-desktop-1y-channel-eur", version: "2" }
const extractNameWithoutQuarter = (listing: any) => {

Choose a reason for hiding this comment

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

I think this logic should not rely on the names of the listings at all, i.e. the name of the listing should be completely ignored. There is no guarantee at all that the names of the listings will always follow the same pattern. On the other hand, all the information about the listing that you can obtain from the name can be obtained from its attributes.

Choose a reason for hiding this comment

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

(An easy fix for this would be to just manually construct the keys for updatedChannelProductList based on the attributes of the listing and remove extractNameWithoutQuarter.)

Copy link
Contributor Author

@minkyngkm minkyngkm Dec 13, 2024

Choose a reason for hiding this comment

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

Hi @amethystant, thanks for your feedback. I thought the name would always follow the pattern (${product?.id}-${duration}y-channel-${currency}), but only the exclusion_group pattern would change.
I didn’t know the product listing included currency and duration other than the name field. I checked the raw product listing, and it includes effectiveDays and currency. I'll make some changes soon so the product listing name won't matter anymore. Thank you!

@minkyngkm minkyngkm force-pushed the wd-16445-quarter branch 2 times, most recently from 4687861 to 60d9b0a Compare December 17, 2024 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants