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

Variant Matching #239

Open
walmat opened this issue Jan 4, 2019 · 4 comments
Open

Variant Matching #239

walmat opened this issue Jan 4, 2019 · 4 comments
Labels
area:task-runner Related to Nebula's Task Runner package priority:low Issues that are low priority don't need to be solved right away type:bug Something isn't working

Comments

@walmat
Copy link
Owner

walmat commented Jan 4, 2019

Describe the bug
Currently we have a pretty inaccurate way of variant matching that will look at just the size and attempt to match it directly. For most sites, this won't be the case.

To Reproduce
Steps to reproduce the behavior:

  1. Make a task for haven
  2. Run it
  3. Watch log fail to match variant

Expected behavior
It should match a size.

Desktop (please complete the following information):

  • OS: All
  • Service: Task runner
  • Version: Beta 1
@walmat walmat added type:bug Something isn't working area:task-runner Related to Nebula's Task Runner package labels Jan 4, 2019
@walmat walmat added this to the Beta 2 Release milestone Jan 4, 2019
@walmat walmat self-assigned this Jan 4, 2019
@pr1sm
Copy link
Collaborator

pr1sm commented Jan 4, 2019

Can you clarify what you mean by matching “by size”? My understanding is that the variant encodes the size information as well as the product.

Do you mean loosening the matching criteria to use the variant only for matching the product, then use the size input to generate a list of matched variants?

If that’s the case, I have a some more clarifying questions:

  • What should we do when the variant size is available, but mismatches the size input (e.g the input variant tells us to get a size 6, but the size input is 8)?
    • If we use both inputs, what should the order of preference be?
  • How should a multiple size input be taken into account?

@walmat
Copy link
Owner Author

walmat commented Jan 4, 2019

Yeah so in my experience it’s just due to sites like haven not having just a plain integer as their option “x” tag, so it’s gets mapped in “variantsBySize” to that. Then when we try to construct all “mappedVariants” it will fail to find them, due to it not just being an integer.

Here’s the line it happens.. like I said, only on sites that meet this criteria.

https://github.com/walmat/nebula/blob/538987a54d09ee0cbbbf480fbf8e2d424777ff94/packages/task-runner/src/shopify/classes/monitor.js#L95
https://github.com/walmat/nebula/blob/538987a54d09ee0cbbbf480fbf8e2d424777ff94/packages/task-runner/src/shopify/classes/monitor.js#L129

@walmat
Copy link
Owner Author

walmat commented Jan 4, 2019

Here’s an example of the variants for a product on Haven for reference as well:

[{"id":15369967140935,"product_id":1563635941447,"title":"8US \/ 7UK \/ 41EUR","price":"129.50","sku":"210000095327","position":1,"compare_at_price":"185.00","fulfillment_service":"manual","inventory_management":"shopify","option1":"8US \/ 7UK \/ 41EUR","option2":null,"option3":null,"created_at":"2018-11-07T07:20:33-08:00","updated_at":"2018-12-31T11:33:24-08:00","taxable":true,"barcode":"","grams":0,"image_id":null,"weight":0.0,"weight_unit":"lb","inventory_item_id":15494935412807,"tax_code":"","requires_shipping":true},{"id":15369967173703,"product_id":1563635941447,"title":"8.5US \/ 7.5UK \/ 42EUR","price":"129.50","sku":"210000095328","position":2,"compare_at_price":"185.00","fulfillment_service":"manual","inventory_management":"shopify","option1":"8.5US \/ 7.5UK \/ 42EUR","option2":null,"option3":null,"created_at":"2018-11-07T07:20:33-08:00","updated_at":"2018-12-31T11:33:25-08:00","taxable":true,"barcode":"","grams":0,"image_id":null,"weight":0.0,"weight_unit":"lb","inventory_item_id":15494935445575,"tax_code":"","requires_shipping":true},{"id":15369967206471,"product_id":1563635941447,"title":"9US \/ 8UK \/ 42.5EUR","price":"129.50","sku":"210000095329","position":3,"compare_at_price":"185.00","fulfillment_service":"manual","inventory_management":"shopify","option1":"9US \/ 8UK \/ 42.5EUR","option2":null,"option3":null,"created_at":"2018-11-07T07:20:33-08:00","updated_at":"2018-12-31T11:28:36-08:00","taxable":true,"barcode":"","grams":0,"image_id":null,"weight":0.0,"weight_unit":"lb","inventory_item_id":15494935478343,"tax_code":"","requires_shipping":true},{"id":15369967239239,"product_id":1563635941447,"title":"9.5US \/ 8.5UK \/ 43EUR","price":"129.50","sku":"210000095330","position":4,"compare_at_price":"185.00","fulfillment_service":"manual","inventory_management":"shopify","option1":"9.5US \/ 8.5UK \/ 43EUR","option2":null,"option3":null,"created_at":"2018-11-07T07:20:33-08:00","updated_at":"2018-12-31T11:28:39-08:00","taxable":true,"barcode":"","grams":0,"image_id":null,"weight":0.0,"weight_unit":"lb","inventory_item_id":15494935511111,"tax_code":"","requires_shipping":true},{"id":15369967009863,"product_id":1563635941447,"title":"10US \/ 9UK \/ 44EUR","price":"129.50","sku":"210000095331","position":5,"compare_at_price":"185.00","fulfillment_service":"manual","inventory_management":"shopify","option1":"10US \/ 9UK \/ 44EUR","option2":null,"option3":null,"created_at":"2018-11-07T07:20:33-08:00","updated_at":"2018-12-31T11:28:31-08:00","taxable":true,"barcode":"","grams":0,"image_id":null,"weight":0.0,"weight_unit":"lb","inventory_item_id":15494935281735,"tax_code":"","requires_shipping":true},{"id":15369967042631,"product_id":1563635941447,"title":"10.5US \/ 9.5UK \/ 44.5EUR","price":"129.50","sku":"210000095332","position":6,"compare_at_price":"185.00","fulfillment_service":"manual","inventory_management":"shopify","option1":"10.5US \/ 9.5UK \/ 44.5EUR","option2":null,"option3":null,"created_at":"2018-11-07T07:20:33-08:00","updated_at":"2018-12-31T11:28:32-08:00","taxable":true,"barcode":"","grams":0,"image_id":null,"weight":0.0,"weight_unit":"lb","inventory_item_id":15494935314503,"tax_code":"","requires_shipping":true},{"id":15369967075399,"product_id":1563635941447,"title":"11US \/ 10UK \/ 45EUR","price":"129.50","sku":"210000095333","position":7,"compare_at_price":"185.00","fulfillment_service":"manual","inventory_management":"shopify","option1":"11US \/ 10UK \/ 45EUR","option2":null,"option3":null,"created_at":"2018-11-07T07:20:33-08:00","updated_at":"2018-12-31T11:28:33-08:00","taxable":true,"barcode":"","grams":0,"image_id":null,"weight":0.0,"weight_unit":"lb","inventory_item_id":15494935347271,"tax_code":"","requires_shipping":true},{"id":15369967108167,"product_id":1563635941447,"title":"12US \/ 11UK \/ 46EUR","price":"129.50","sku":"210000095334","position":8,"compare_at_price":"185.00","fulfillment_service":"manual","inventory_management":"shopify","option1":"12US \/ 11UK \/ 46EUR","option2":null,"option3":null,"created_at":"2018-11-07T07:20:33-08:00","updated_at":"2019-01-01T15:30:35-08:00","taxable":true,"barcode":"","grams":0,"image_id":null,"weight":0.0,"weight_unit":"lb","inventory_item_id":15494935380039,"tax_code":"","requires_shipping":true}],"options":[{"id":2130761154631,"product_id":1563635941447,"name":"Size","position":1,"values":["8US \/ 7UK \/ 41EUR","8.5US \/ 7.5UK \/ 42EUR","9US \/ 8UK \/ 42.5EUR","9.5US \/ 8.5UK \/ 43EUR","10US \/ 9UK \/ 44EUR","10.5US \/ 9.5UK \/ 44.5EUR","11US \/ 10UK \/ 45EUR","12US \/ 11UK \/ 46EUR"]}],"images":[{"id":4480954630215,"product_id":1563635941447,"position":1,"created_at":"2018-11-08T08:24:51-08:00","updated_at":"2018-11-08T08:25:12-08:00","alt":"nike Air Zoom Pegasus 35 Shield NRG Black\/Reflect Silver","width":2048,"height":2048,"src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0051\/7042\/products\/HAVEN-Nike-Air-Zoom-Pegasus-35-Shield-NRG-BLACK-REFLECT-SILVER-1.jpg?v=1541694312","variant_ids":[]},{"id":4480954728519,"product_id":1563635941447,"position":2,"created_at":"2018-11-08T08:24:53-08:00","updated_at":"2018-11-08T08:25:31-08:00","alt":"nike Air Zoom Pegasus 35 Shield NRG Black\/Reflect Silver","width":2048,"height":2048,"src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0051\/7042\/products\/HAVEN-Nike-Air-Zoom-Pegasus-35-Shield-NRG-BLACK-REFLECT-SILVER-2.jpg?v=1541694331","variant_ids":[]},{"id":4480954761287,"product_id":1563635941447,"position":3,"created_at":"2018-11-08T08:24:55-08:00","updated_at":"2018-11-08T08:25:57-08:00","alt":"nike Air Zoom Pegasus 35 Shield NRG Black\/Reflect Silver","width":2048,"height":2048,"src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0051\/7042\/products\/HAVEN-Nike-Air-Zoom-Pegasus-35-Shield-NRG-BLACK-REFLECT-SILVER-3.jpg?v=1541694357","variant_ids":[]},{"id":4480954794055,"product_id":1563635941447,"position":4,"created_at":"2018-11-08T08:24:56-08:00","updated_at":"2018-11-08T08:26:02-08:00","alt":"nike Air Zoom Pegasus 35 Shield NRG Black\/Reflect Silver","width":2048,"height":2048,"src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0051\/7042\/products\/HAVEN-Nike-Air-Zoom-Pegasus-35-Shield-NRG-BLACK-REFLECT-SILVER-4.jpg?v=1541694362","variant_ids":[]}]

@pr1sm
Copy link
Collaborator

pr1sm commented Jan 4, 2019

Ah, I see -- I'm talking about something specific to entering a variant-type product. This is a problem in general with how we group variants by size. Sorry for the confusion!

We'll need some function to properly check for the correct size (number) and correct region within a string. Our current implementation with Haven is broken on two levels:

  1. The option1 value of the variant object is not a number as you pointed out, but a collection of regional sizes separated by /. This will indeed break the groupBy call.
  2. The title segment we really need is the whole title, since we could need all of these segments depending on the regional size. Our current implementation will split the title based on / and only return 8.5US as the size even though we might want to match for 42EUR. Even if we were able to extract the "number" part of the string out, we would never get a match since we've lost the Europe size data and are only looking for US sizes. (NOTE: this wouldn't necessarily matter in this case since the option1 value would be used as it is non-null, but if we had the same format for the variant title and the option keys didn't exist on the variant, we would hit this error-causing case)

The first case can be solved by having a "size extraction" utility method that takes the "size" value we have (which potentially isn't a number) and converts it to a valid number (or string containing the number value). This could be fed to the groupBy call to ensure that we only have groupings based on single sizes.

The second case will be a harder problem to solve. We would need to add regional data to sizes in the frontend. This would help us separate a 7.5US vs 7.5UK, something we currently don't do (AFAIK, but things could have changed... feel free to correct me if I'm wrong 😅). We would then need to further parse any incoming size values when matching to check for regional information choose the correct regional size for grouping.

@walmat walmat added the priority:urgent Issues that need to be solved right away label Jan 12, 2019
pr1sm added a commit that referenced this issue Jan 17, 2019
Some sites include unsupported size option values, which affects our variant group matching. This commit adds a temporary workaround until the actual issue (#239) is addressed.

Additionally, a linter error is fixed, some unnecessary log statements are removed, and another log statement is adjusted to only display relevant information.
pr1sm added a commit that referenced this issue Jan 17, 2019
* Handle Captcha State

This commit adds a missing handler for the captcha state. This uses the checkouts handle request captcha method to request a captcha and wait for the token. The handler has also been updated to include error checking.

* Use Protocol Interceptors to Load Captcha Page

This commit adds a protocol interceptor to load our captcha html instead of the regular html for other sites.

This commit also updates the captcha server middleware stack to better handle loading assets such as images/styling/js while still redirecting everything else to the captcha html page.

Issue: #204

* Add Temporary Workaround for Unhandled Size Option Formats

Some sites include unsupported size option values, which affects our variant group matching. This commit adds a temporary workaround until the actual issue (#239) is addressed.

Additionally, a linter error is fixed, some unnecessary log statements are removed, and another log statement is adjusted to only display relevant information.

* Fix Various Captcha Related Bugs

This commit addresses some (not all!) captcha related bugs:
- Captcha Window Reloads are now handled properly
- Redundant Captcha Reset calls are removed
- Attempting to add >5 captcha windows no longer crashes the frontend

These are some small bugs that fall under the scope of this branch. Other larger bugs that require separate issues are not fixed in this commit.
@pr1sm pr1sm modified the milestones: Beta 3 Release, Beta 4 Release Jan 18, 2019
@walmat walmat removed this from the Beta 4 Release milestone Feb 1, 2019
@pr1sm pr1sm added this to the Beta 6 Release milestone Feb 8, 2019
@walmat walmat removed their assignment Feb 21, 2019
@pr1sm pr1sm modified the milestones: Beta 6 Release, Beta 7 Release Feb 23, 2019
@pr1sm pr1sm self-assigned this Feb 25, 2019
@pr1sm pr1sm removed this from the Beta 7 Release milestone Mar 16, 2019
@pr1sm pr1sm removed their assignment Mar 16, 2019
@pr1sm pr1sm added priority:low Issues that are low priority don't need to be solved right away and removed priority:urgent Issues that need to be solved right away labels Mar 16, 2019
This was referenced May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:task-runner Related to Nebula's Task Runner package priority:low Issues that are low priority don't need to be solved right away type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants