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

Reduce calls to wp_count_posts( 'product' ) from OnboardingTasks #45125

Merged
merged 3 commits into from Feb 27, 2024

Conversation

chihsuan
Copy link
Member

@chihsuan chihsuan commented Feb 26, 2024

Submission Review Guidelines:

Changes proposed in this Pull Request:

Closes #43768.

We are calling wp_count_posts( 'product' ) on each admin request. This PR reduces the calls via transient caching.

Besides, similar to tasklist improvement in #44442, improves task performance by having cheaper check first.

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Go to WooCommerce > Home
  2. Run wp transient get woocommerce_product_task_product_count_transient, observe it returns 0
  3. Click on Add products
  4. Observe the product task is shown
  5. Add a physical product and publish
  6. Go back to the Home screen
  7. Observe the product task is completed
  8. Run wp transient get woocommerce_product_task_product_count_transient, observe it returns 1
  9. Go to /wp-admin/edit.php?post_type=product
  10. Delete the product
  11. Run wp transient get woocommerce_product_task_product_count_transient, observe it returns 0
  12. Go back to the Home screen
  13. Observe the product task is incomplete.
  14. Go to /wp-admin/edit.php?post_status=trash&post_type=product
  15. Restore product
  16. Run wp transient get woocommerce_product_task_product_count_transient, observe it returns 1

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Reduce calls to wp_count_posts( 'product' ) from OnboardingTasks

Comment

@chihsuan chihsuan marked this pull request as ready for review February 26, 2024 11:40
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Feb 26, 2024
@chihsuan chihsuan closed this Feb 26, 2024
@chihsuan chihsuan reopened this Feb 26, 2024
@chihsuan chihsuan self-assigned this Feb 26, 2024
@chihsuan chihsuan requested review from a team, psealock and moon0326 February 26, 2024 11:53
Copy link
Contributor

Hi @psealock, @moon0326, @woocommerce/ghidorah

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

Copy link
Contributor

github-actions bot commented Feb 26, 2024

Test Results Summary

Commit SHA: 82f24af

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 37s
E2E Tests321002603477m 18s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

Copy link
Contributor

@moon0326 moon0326 left a comment

Choose a reason for hiding this comment

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

This is a nice addition 👍

LGTM and tested well 🚀

Copy link
Contributor

@psealock psealock left a comment

Choose a reason for hiding this comment

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

Code looks great and tests well 🚀

@chihsuan chihsuan enabled auto-merge (squash) February 27, 2024 05:21
@chihsuan chihsuan merged commit 707c555 into trunk Feb 27, 2024
30 of 31 checks passed
@chihsuan chihsuan deleted the update/reduce-count-products branch February 27, 2024 05:30
@github-actions github-actions bot added this to the 8.8.0 milestone Feb 27, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Feb 27, 2024
@alopezari alopezari added needs: internal testing Indicates if the PR requires further testing conducted by Solaris status: analysis complete Indicates if a PR has been analysed by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels Feb 27, 2024
Konamiman pushed a commit that referenced this pull request Mar 13, 2024
)

* Reduce product count calls via transient caching

* Check has_previously_completed first

* Add changefile(s) from automation for the following project(s): woocommerce

---------

Co-authored-by: github-actions <github-actions@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: internal testing Indicates if the PR requires further testing conducted by Solaris plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement]: reduce calls to wp_count_posts( 'product' ) from OnboardingTasks
4 participants