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

[CYS] Patterns Migration: Performance - ensure the initial request to fetch patterns from the PTK is async #47551

Merged
merged 46 commits into from
May 29, 2024

Conversation

albarin
Copy link
Contributor

@albarin albarin commented May 16, 2024

Submission Review Guidelines:

Changes proposed in this Pull Request:

This PR ensures requests to the PTK API are done async when:

  • The woocommerce_allow_tracking option changes to enabled.
  • The WooCommerce plugin is activated (if woocommerce_allow_tracking is enabled).
  • The WooCommerce plugin is updated.

Also ensures that the PTK patterns cache is flushed when:

  • The WooCommerce plugin is deactivated.
  • The woocommerce_allow_tracking option is disabled.

Closes #47403

How to test the changes in this Pull Request:

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

Pre-requisites

  • Go to wp-admin/tools.php?page=woocommerce-admin-test-helper, go to Features, and enable the pattern-toolkit-full-composability.
  • Install the Transients Manager plugin (this is just for convenience since it provides an easy way of removing transients from the database).

When the woocommerce_allow_tracking option changes to enabled, PTK patterns are fetched

  1. Go to wp-admin/admin.php?page=wc-settings&tab=advanced&section=woocommerce_com and make sure Allow usage of WooCommerce to be tracked is unchecked.
  2. On the same page, check the option from the previous step and Save.
  3. Go to wp-admin/tools.php?page=action-scheduler, search for the fetch_patterns action, and make sure it was scheduled.
  4. Click on Run under the action name if it is still pending and wait until is completed.
  5. Go to wp-admin/tools.php?s=ptk_patterns&page=transients-manager and make sure the ptk_patterns transient is set.
  6. Create a new page or post and make sure you can insert the Intro: Left-aligned header and button pattern.

When the WooCommerce plugin is activated (if woocommerce_allow_tracking is enabled), PTK patterns are fetched

  1. Go to wp-admin/admin.php?page=wc-settings&tab=advanced&section=woocommerce_com and make sure Allow usage of WooCommerce to be tracked is checked.
  2. Deactivate the WooCommerce plugin.
  3. Go to wp-admin/tools.php?s=ptk_patterns&page=transients-manager and delete the ptk_patterns transient if present.
  4. Activate it again.
  5. Go to wp-admin/tools.php?page=action-scheduler, search for the fetch_patterns action, and make sure it was scheduled.
  6. Click on Run under the action name if it is still pending and wait until is completed.
  7. Create a new page or post and make sure you can insert the Intro: Left-aligned header and button pattern.

When the WooCommerce plugin is updated, PTK patterns are fetched

  1. Install WooCommerce from this ZIP file.
  2. Go to wp-admin/tools.php?s=ptk_patterns&page=transients-manager and delete the ptk_patterns transient.
  3. Go to Plugins and click on update to update the WooCommerce plugin.
  4. Go to wp-admin/tools.php?page=action-scheduler, search for the fetch_patterns action, and make sure it was scheduled (don't worry if it fails, it should at this point).

When the WooCommerce plugin is deactivated, PTK patterns are flushed

  1. Go to wp-admin/admin.php?page=wc-settings&tab=advanced&section=woocommerce_com and make sure Allow usage of WooCommerce to be tracked is checked.
  2. Go to wp-admin/tools.php?s=ptk_patterns&page=transients-manager and make sure the ptk_patterns transient is set.
  3. Go to Plugins and disable WooCommerce.
  4. Go to wp-admin/tools.php?s=ptk_patterns&page=transients-manager and make sure the ptk_patterns transient is not present.
  5. Create a new page or post and make sure you cannot insert the Intro: Left-aligned header and button pattern.

When the woocommerce_allow_tracking option is disabled, PTK patterns are flushed

  1. Go to wp-admin/admin.php?page=wc-settings&tab=advanced&section=woocommerce_com and make sure Allow usage of WooCommerce to be tracked is checked.
  2. Go to wp-admin/tools.php?s=ptk_patterns&page=transients-manager and make sure the ptk_patterns transient is set.
  3. Go to wp-admin/admin.php?page=wc-settings&tab=advanced&section=woocommerce_com, uncheck Allow usage of WooCommerce to be tracked, and save.
  4. Go to wp-admin/tools.php?s=ptk_patterns&page=transients-manager and make sure the ptk_patterns transient is not present.
  5. Create a new page or post and make sure you cannot insert the Intro: Left-aligned header and button pattern.

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

[CYS] Ensure fetch PTK patterns requests are always done async to improve performance.

Comment

albarin and others added 29 commits May 8, 2024 14:38
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label May 16, 2024
Copy link
Contributor

github-actions bot commented May 17, 2024

Hi @gigitux, @nefeline, @kmanijak,

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

@albarin albarin requested review from gigitux and nefeline May 17, 2024 11:51
Copy link
Member

@nefeline nefeline left a comment

Choose a reason for hiding this comment

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

Excellent work, @albarin !

I just noticed some mixups in the testing instructions:

When the woocommerce_allow_tracking option changes to enabled, PTK patterns are fetched

Go to wp-admin/admin.php?page=wc-settings&tab=advanced&section=woocommerce_com and make sure Allow usage of WooCommerce to be tracked is unchecked.

In this case you meant "checked", right?

When the WooCommerce plugin is updated, PTK patterns are fetched

Install WooCommerce from this ZIP file.

The link to zip file is missing :)

Apart from that, everything else is testing great and working as expected!

Copy link
Contributor

@gigitux gigitux left a comment

Choose a reason for hiding this comment

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

Great work! Great job on adding unit tests 🚀

I'm pre-approving the PR, but I left a minor comment! Let me know what you think about it!

Install WooCommerce from this ZIP file.

Regarding this step, I tested it installing the same zip generated by this PR twice. In any case, as @nefeline noted, it makes sense uploaded a zip file!

@albarin
Copy link
Contributor Author

albarin commented May 28, 2024

In this case you meant "checked", right?

@nefeline I think it's correct because the test is to confirm that patterns are fetched when it changes from unchecked to checked. So in step 1, we uncheck it, and then in step 2, we check it. Does it make sense?

@nefeline @gigitux Thanks for your reviews 🙏 I'll update the zip! 🤦

Base automatically changed from add-patterns-from-ptk to trunk May 28, 2024 12:42
@nefeline
Copy link
Member

nefeline commented May 28, 2024

@nefeline I think it's correct because the test is to confirm that patterns are fetched when it changes from unchecked to checked. So in step 1, we uncheck it, and then in step 2, we check it. Does it make sense?

🤔 maybe I'm missing something here, I think the title is not matching the content, is it?

Screenshot 2024-05-28 at 15 47 22

Edit: nevermind, I missed step 2, all good 🙌

@albarin albarin merged commit 02fdd91 into trunk May 29, 2024
36 checks passed
@albarin albarin deleted the 47403-async-ptk-request branch May 29, 2024 09:46
@github-actions github-actions bot added this to the 9.1.0 milestone May 29, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label May 29, 2024
@alvarothomas alvarothomas 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 May 29, 2024
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.

CYS > Patterns Migration: Performance - ensure the initial request to fetch patterns from the PTK is async
4 participants