-
Notifications
You must be signed in to change notification settings - Fork 21
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
Create product statuses jobs for each page token #2255
Create product statuses jobs for each page token #2255
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## feature/refactor-product-stats #2255 +/- ##
==================================================================
+ Coverage 58.9% 59.0% +0.1%
+ Complexity 4266 4178 -88
==================================================================
Files 460 457 -3
Lines 18055 17702 -353
==================================================================
- Hits 10628 10443 -185
+ Misses 7427 7259 -168
Flags with carried forward coverage won't be shown. Click here to find out more.
|
I didn't want to do a full review of this PR, but just had a few comments.
That does seem to be an accurate calculation moving forward, although I'm wondering if that's totally backwards compatible since there might be products with the NOT_SYNCED status already set. For the sync stats calculation that seems to be fine, but do we need to consider unsetting the NOT_SYNCED status for products? Another question, is should total WC products be done with a product type filter? Wouldn't the Merchants perceive that an excluded product type would be unsynced? Also for intermediate data in between jobs, I see it's being stored in a transient. Given that a transient can disappear at any time, it would be safer to use an option, like is done in the UpdateSyncableProductsCount. I noticed ProductSyncStats was being removed, if we are going to merge this PR early, then shouldn't we leave that in, since it's still used in the UI. |
Thanks @mikkamp for your comments:
Can you help me to see a scenario where having the NOT_SYNCED status already set could potentially cause an issue? Or vice versa? If it is an issue, we could consider creating a job that runs once to unset the NOT_SYNCED status for products.
Do you mean, that the total number of products should be the count of all products, regardless of their type (including variations)?
TIL, I thought the transient would stay until its expiration time, but it looks like it can get deleted even sooner.
|
@mikkamp and @martynmjones, I changed the PR to use an option for the intermediate data and reverted the change of removing ProductSyncStats. |
I was mainly thinking about the point where you mentioned:
But I see now that's for individual products so we can combine both NOT_SYNCED and not set as the same values. The other thought I was worried about is the querying, but it seems
Yes exactly, because there could be lots of unsupported product types. Variations use a different Thanks for switching the transient to an option, it's just a little more reliable and hard to troubleshoot if a transient ever gets cleared. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @jorgemd24, thank you for improving the efficiency of this feature.
Aside from the comments that have already been addressed above I can't see any problems with these changes. Tested the branch in several different scenarios and have consistently had the correct stats built and the scheduled actions behave as to be expected. So LGTM ✅
Thanks @martynmjones for your time reviewing this PR! |
Changes proposed in this Pull Request:
Part of #2146 & #2250
In #2229 we've added a background job that handles calculating product stats, bringing all products from MC and updating their status in WooCommerce.
This PR will allow the background job to generate multiple tasks based on the
$next_page_token
, helping us spread out resource usage more effectively.While working on this I noticed that we were changing the product status to "not synced" to calculate the unsynced products in MC. But, I think that's unnecessary. The actual count of unsynced products will simply be: NOT_SYNCED = WooCommerce Products ('simple', 'variable') - MC Products (with variants grouped).
In the case that we need to display the MC status, like in the Product Feed section, we can assume that if a WC product doesn't have an MC status, it's not synced in MC. I'm open to hearing other thoughts on this.
Screenshots:
woocommerce_gla_product_view_report_page_size
.GET gla/mc/product-statistics/refresh
gla/jobs/update_merchant_product_statuses
Additional details:
Changelog entry