-
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
API PULL - Overview Stats - delete stale mc statuses #2329
API PULL - Overview Stats - delete stale mc statuses #2329
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## add/display-error-job-mc-status #2329 +/- ##
===================================================================
+ Coverage 62.7% 64.3% +1.6%
- Complexity 4249 4251 +2
===================================================================
Files 751 458 -293
Lines 21777 18046 -3731
Branches 542 0 -542
===================================================================
- Hits 13653 11606 -2047
+ Misses 7668 6440 -1228
+ Partials 456 0 -456
Flags with carried forward coverage won't be shown. Click here to find out more.
|
I added this to the list of TODO in #2146 |
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.
Hi @jorgemd24 thanks for working on this.
✅ LGTM the issues are refreshed and loaded as always.
I left a minor comment about the since
tag. But approved in advance
* | ||
* @throws InvalidMeta If the meta key isn't valid. | ||
*/ | ||
public function delete_all_values( string $meta_key ) { |
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.
@since
tag is missed
Changes proposed in this Pull Request:
Part of #2146 & #2250
Since the product's MC status depends on the status in Google Merchant Center, if the product no longer exists in the MC, the local MC status will never be deleted. Hence, this PR will clear all the MC statuses, allowing us to start fresh when pulling the product MC statuses.
In the previous #2257, we refactor some code to use WC Crud classes instead of directly querying the database. However, in this scenario, I think deleting all the product's post meta
_wc_gla_mc_status
with a single query would be much more efficient than using the CRUD classes and loading all the products.I increased the transient expiration time to 12 hours. Because currently, whenever a product is created, updated, or deleted, the transient cache is cleared because it calls the hooks (
woocommerce_gla_batch_updated_products
andwoocommerce_gla_batch_deleted_products
). Therefore, I believe it's unnecessary to remove the transient cache every hour if no changes to products have occurred.google-listings-and-ads/src/Event/ClearProductStatsCache.php
Lines 39 to 50 in 8ebe1ec
With the new approach of notifications, we could do something similar, once a product has been notified to Google we could clear the cache.
Screenshots:
Detailed test instructions:
wc/gla/mc/product-statistics/refresh
gla/jobs/update_merchant_product_statuses/process_item
is scheduled.page=wc-admin&path=%2Fgoogle%2Fproduct-feed
and wait until the stats are fetched.Additional details:
Changelog entry