Skip to content

Conversation

@nathanss
Copy link
Contributor

@nathanss nathanss commented Jan 11, 2023

All Submissions:

Changes proposed in this Pull Request:

Add new filter to add additional clauses for SQL statement in Variations report

This should allow extensions to customize the results from the query.

  • This PR is a very minor change/addition and does not require testing instructions (if checked you can ignore/remove the next section).

How to test the changes in this Pull Request:

  • Check the Analytics > Variations report for regressions. Nothing should change unless there's an extension using the filter to change the behavior.

There's a private extension in development to test that: check https://github.com/Automattic/swag-store-custom-analytics/pull/2

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you created a changelog file for each project being changed, ie pnpm --filter=<project> changelog add?

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

@github-actions github-actions bot added focus: react admin plugin: woocommerce Issues related to the WooCommerce Core plugin. labels Jan 11, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jan 11, 2023

Test Results Summary

Commit SHA: cafd7a2

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202611m 11s
E2E Tests189006019515m 51s

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.

@AnnaMag AnnaMag added the Reports/Analytics Issues related to analytics section. label Jan 17, 2023
@AnnaMag AnnaMag added this to the 7.4.0 milestone Jan 17, 2023
Copy link
Contributor

@AnnaMag AnnaMag left a comment

Choose a reason for hiding this comment

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

LGTM!

Thanks @nathanss.

@nathanss nathanss merged commit 924e64a into trunk Jan 19, 2023
@nathanss nathanss deleted the add/new-variation-report-filter branch January 19, 2023 19:19
adrianduffell pushed a commit that referenced this pull request Jan 20, 2023
…ons report (#36378)

* Apply filter to get additional sql to include variations with no orders

* Add join only when correct option is selected

* Some more desperate tests

* Analytics: use a sepoarate query for data without orders.

* Change 'experimental_woocommerce_analytics_variations_additional_clause' filter to apply sql clauses directly

* Cleanup

* Add changelog

* Fix PHPCS issues

* Add docblock and update the filter name

* Improve docblock of new filter

* Add Since 7.4.0 on filter

* Move union statement before order by statement

* Apply filters before running the db count statement and add sql select clause before

* Remove with sql clause since it's not compatible with MySQL 5.7

* Remove additional spaces

* Fix bug caught by unit test in which $variations_query is overwritten because the assignment was outside the 'else' statement

Co-authored-by: AnnaMag <[email protected]>
vedanshujain pushed a commit that referenced this pull request Jan 25, 2023
…ons report (#36378)

* Apply filter to get additional sql to include variations with no orders

* Add join only when correct option is selected

* Some more desperate tests

* Analytics: use a sepoarate query for data without orders.

* Change 'experimental_woocommerce_analytics_variations_additional_clause' filter to apply sql clauses directly

* Cleanup

* Add changelog

* Fix PHPCS issues

* Add docblock and update the filter name

* Improve docblock of new filter

* Add Since 7.4.0 on filter

* Move union statement before order by statement

* Apply filters before running the db count statement and add sql select clause before

* Remove with sql clause since it's not compatible with MySQL 5.7

* Remove additional spaces

* Fix bug caught by unit test in which $variations_query is overwritten because the assignment was outside the 'else' statement

Co-authored-by: AnnaMag <[email protected]>
@stian-overasen
Copy link
Contributor

The experimental_woocommerce_analytics_variations_additional_clauses filter does not work @nathanss, since the return value from apply_filters() is not assigned back to $query_args.

The code should be:

$query_args = apply_filters( 'experimental_woocommerce_analytics_variations_additional_clauses', $query_args, $this->subquery );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin: woocommerce Issues related to the WooCommerce Core plugin. Reports/Analytics Issues related to analytics section.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants