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

Update/optimize calls to advertisers countries #805

Merged
merged 7 commits into from
Aug 9, 2023

Conversation

budzanowski
Copy link
Collaborator

@budzanowski budzanowski commented Aug 7, 2023

Changes proposed in this Pull Request:

Closes #800 .

We have been notified that there are too many calls to the advertisers/countries endpoint. This PR helps to reduce the number of calls via two things:

  1. Increase the time for which the response is cached from 1 to 2 days. This endpoint is basically static so we could increase the number even higher if we would be forced to.
  2. Detect if we are connected and if not abort the API call - go straight to the fallback list.

Detailed test instructions:

The plugin should not be connected.

  1. Set a breakpoint at Pinterest_For_Woocommerce_Ads_Supported_Countries::get_countries
  2. Open the Marketing -> Pinterest page.
  3. Call to the get_countries should not trigger the API call but the fallback should be used.
  4. Connect the plugin
  5. After connection the call to the get_countries should trigger an API call ( first time )
  6. Refresh the page - the next call should use the cached value.

Changelog entry

Tweak - Don't fetch the allowed countries list when not connected.
Tweak - Increase allowed countries cache lifetime to two days.

@github-actions github-actions bot added the changelog: update Big changes to something that wasn't broken. label Aug 7, 2023
@budzanowski budzanowski self-assigned this Aug 7, 2023
@budzanowski budzanowski requested a review from a team August 7, 2023 14:44
Copy link
Contributor

@JPry JPry left a comment

Choose a reason for hiding this comment

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

Works as described, just needs the PHPCS fix and the one suggestion I made before merging.

@budzanowski budzanowski merged commit 42d3419 into develop Aug 9, 2023
7 checks passed
@budzanowski budzanowski deleted the update/optimize-calls-to-advertisers-countries branch August 9, 2023 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: update Big changes to something that wasn't broken.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimize calls to "advertisers/countries"
2 participants