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

Filter publications returned by TwG datapoint #5653

Closed
aaemnnosttv opened this issue Aug 3, 2022 · 8 comments
Closed

Filter publications returned by TwG datapoint #5653

aaemnnosttv opened this issue Aug 3, 2022 · 8 comments
Labels
Module: Thank with Google Thank with Google module related issues P0 High priority PHP Type: Enhancement Improvement of an existing feature

Comments

@aaemnnosttv
Copy link
Collaborator

aaemnnosttv commented Aug 3, 2022

Feature Description

The TwG datapoint for GET:publications currently returns all publications a user has access to. According to the design doc, this should be filtered to a subset of publications that are relevant for the current site, but also for TwG as it can return other kinds of publications as well.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • The TwG GET:publications endpoint's response handling should be adjusted so that the returned publications are filtered to only return those that satisfy both requirements:
    • The publication has paymentOptions -> thankStickers set to true.
    • The publication has publicationPredicates -> businessPredicates -> supportsSiteKit set to true but only if the onboarding state is ONBOARDING_COMPLETE.

Implementation Brief

In the includes/Modules/Thank_With_Google.php, modify the parse_data_response protected function to filter out publications that do not satisfy the above requirements.

  • Get the $response->getPublications() to a variable.
  • Using array_filter helper loop through the $response->getPublications() and do the following logic in the callback function:
    • If the publication object does not have paymentOptions->thankStickers set to true, remove the publication from the array.
    • If the publication object does not have publicationPredicates->businessPredicates->supportsSiteKit set to true, remove the publication from the array.
    • In other words, return the array of publications that satisfy both requirements.
  • Return the filtered $response->getPublications() to the parse_data_response function.

Test Coverage

  • No new tests are to be added.

QA Brief

  • Ensure you have active publications and have access to request the publications endpoint.
  • Run the getPublications selector in the browser console - googlesitekit.data.select('modules/thank-with-google').getPublications().
  • Ensure the publications array of objects met the criteria mentioned in the AC.

Changelog entry

  • Ensure Thank with Google API results are filtered properly.
@techanvil
Copy link
Collaborator

IB ✅

@techanvil techanvil removed their assignment Aug 9, 2022
@hussain-t hussain-t self-assigned this Aug 10, 2022
@hussain-t hussain-t removed their assignment Aug 15, 2022
@tofumatt tofumatt assigned tofumatt and unassigned tofumatt Aug 15, 2022
@wpdarren wpdarren self-assigned this Aug 17, 2022
@wpdarren
Copy link
Collaborator

QA Update: ✅

Verified:

  • The TwG GET:publications endpoint's response handling are adjusted so that the returned publications are filtered to only return those that satisfy both requirements:
    • The publication has paymentOptions -> thankStickers set to true.
    • The publication has publicationPredicates -> businessPredicates -> supportsSiteKit set to true.

image

@wpdarren wpdarren removed their assignment Aug 17, 2022
@aaemnnosttv
Copy link
Collaborator Author

aaemnnosttv commented Aug 17, 2022

⚠️ Looks like publicationPredicates and/or businessPredicates are only present on publications which have completed the onboarding process. I'm confirming this with the team, but if so, we'd need to remove these from the filtering otherwise we won't be able know when a user has a publication which has remaining uncompleted onboarding steps. thankStickers however are not affected by this so that can remain.

Also, for users who have publications filtered out (as I do), the response type is now an object rather than an array, so this should be fixed.
image

@aaemnnosttv aaemnnosttv self-assigned this Aug 17, 2022
@aaemnnosttv
Copy link
Collaborator Author

The TwG team confirmed the above, so unfortunately we cannot filter publications to those that have publicationPredicates->businessPredicates->supportsSiteKit as this will not be present until the onboarding is completed (i.e. publication is fully active).

@aaemnnosttv
Copy link
Collaborator Author

I've updated the ACs and created a follow-up PR for the changes.

@aaemnnosttv aaemnnosttv removed their assignment Aug 18, 2022
@tofumatt tofumatt self-assigned this Aug 18, 2022
@tofumatt tofumatt removed their assignment Aug 18, 2022
@wpdarren wpdarren self-assigned this Aug 18, 2022
@wpdarren
Copy link
Collaborator

QA Update: ✅

Verified:

The TwG GET:publications endpoint's response handling is adjusted so that the returned publications are filtered to only return those that satisfy both requirements:

  • The publication has paymentOptions -> thankStickers set to true.
  • The publication has publicationPredicates -> businessPredicates -> supportsSiteKit set to true but only if the onboarding state is ONBOARDING_COMPLETE.

image

I tested this when the status was NONE on the Thank with Google publication status in the tester plugin and when I pasted the code in the QAB, the result was undefined. Therefore the endpoints only appear when onboarding is completed.

image

@wpdarren wpdarren removed their assignment Aug 19, 2022
@hussain-t
Copy link
Collaborator

Thanks for clarifying and addressing this, @aaemnnosttv 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module: Thank with Google Thank with Google module related issues P0 High priority PHP Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

7 participants
@tofumatt @aaemnnosttv @felixarntz @techanvil @hussain-t @wpdarren and others