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

feat: avoid unnecessary queries if there are no published sponsors #46

Merged
merged 3 commits into from
Nov 21, 2020

Conversation

dkoo
Copy link
Contributor

@dkoo dkoo commented Nov 20, 2020

All Submissions:

Changes proposed in this Pull Request:

This adds a check for published sponsor posts before running any additional sponsor-related queries. If the site has no published sponsors, then there's no need to proceed with the sponsor queries.

How to test the changes in this Pull Request:

  1. On a site with debug bar installed, ensure you have at least one published sponsor post.
  2. On master, view the homepage and use debug bar to count the number of queries occurring with newspack_spnsrs_cpt as a query param. It will likely be a double-digit number, at least one per post rendered on the page.
  3. Check out this branch and set all sponsor posts to draft status, so there are zero published sponsor posts.
  4. Refresh the homepage and use the debug bar to count queries with newspack_spnsrs_cpt again. The number should now be just 1, and hopefully the "total query time" should also be slightly less.

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 successfully ran tests with your changes locally?

@dkoo dkoo self-assigned this Nov 20, 2020
@dkoo dkoo mentioned this pull request Nov 20, 2020
6 tasks
@dkoo dkoo merged commit 587729c into master Nov 21, 2020
@dkoo dkoo deleted the feat/avoid-unnecessary-queries branch November 21, 2020 18:06
matticbot pushed a commit that referenced this pull request Nov 24, 2020
# [1.3.0-alpha.1](v1.2.1...v1.3.0-alpha.1) (2020-11-24)

### Features

* avoid unnecessary queries if there are no published sponsors ([#46](#46)) ([587729c](587729c))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.3.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Nov 24, 2020
# [1.3.0](v1.2.1...v1.3.0) (2020-11-24)

### Features

* avoid unnecessary queries if there are no published sponsors ([#46](#46)) ([587729c](587729c))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.3.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

3 participants