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

Issue-142: Add option to pull Trending posts #143

Merged
merged 22 commits into from
Mar 7, 2024

Conversation

mogmarsh
Copy link
Collaborator

@mogmarsh mogmarsh commented Mar 1, 2024

Description

The backfill should allow pulling featured posts from Parse.ly and eventually lede-beacon. We have now added the functionality to also pull trending posts, enhancing the variety of content that can be used for backfill. Editor controls have been set up to facilitate the selection of these posts, and a new endpoint has been developed to handle these queries effectively.

Use Case

A user can select trending posts for the backfill source, in addition to the previously available options. This expansion allows for a more dynamic content selection process.

Issue

Add option to pull Trending posts - #142

@mogmarsh mogmarsh marked this pull request as ready for review March 5, 2024 16:49
Copy link
Member

@dlh01 dlh01 left a comment

Choose a reason for hiding this comment

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

High-level it's looking good. I've got some questions on the details.

blocks/query/block.json Outdated Show resolved Hide resolved
blocks/query/index.php Outdated Show resolved Hide resolved
src/class-plugin-curated-posts.php Outdated Show resolved Hide resolved
src/class-trending-post-queries.php Outdated Show resolved Hide resolved
src/class-trending-post-queries.php Outdated Show resolved Hide resolved
src/features/class-rest-api.php Outdated Show resolved Hide resolved
src/features/class-rest-api.php Outdated Show resolved Hide resolved
src/features/class-rest-api.php Show resolved Hide resolved
src/features/class-rest-api.php Show resolved Hide resolved
}
if ( empty( $posts ) ) {
$query = new \WP_Query( $args );
$posts = $query->posts;
Copy link
Member

Choose a reason for hiding this comment

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

Am I following that the "correct" results of this endpoint would be the same results that are going to appear on the frontend for the block? Would we want to use the same Post_Queries instance that are used when filtering the block output here instead of a plain WP_Query?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dlh01 the "correct" results will not have any pinned posts or deduplication. That all happens client side in the editor, so it can be just a plain WP_Query or the Post_Queries equivalent of a plain WP_Query. We do want to support the trending override, of course. So we could do just Trending_Post_Queries and Variable_Post_Queries.

blocks/query/edit.tsx Outdated Show resolved Hide resolved
/**
* Pull trending posts from Parsely.
*/
final class Trending_Post_Queries implements Post_Queries {
Copy link
Member

Choose a reason for hiding this comment

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

If this is specific to Parse.ly, then it should be named as such. If it's intended to be a generic trending posts class, then it should be structured so that it supports multiple providers, of which Parse.ly will be the first (and we could add other providers like GA4 later).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kevinfodness supporting multiple providers was my plan... I kind of figured we would sort out how structure it when we added the second provider.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, we're using named arguments instead of positional ones, this works for me!

src/features/class-parsely-support.php Outdated Show resolved Hide resolved
src/features/class-parsely-support.php Outdated Show resolved Hide resolved
src/features/class-parsely-support.php Outdated Show resolved Hide resolved
src/features/class-parsely-support.php Outdated Show resolved Hide resolved
src/features/class-parsely-support.php Outdated Show resolved Hide resolved
src/features/class-parsely-support.php Outdated Show resolved Hide resolved
src/features/class-rest-api.php Outdated Show resolved Hide resolved
Copy link
Member

@attackant attackant left a comment

Choose a reason for hiding this comment

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

Looks good but feel free to keep getting others feedback on this if you need to 🐙

@mogmarsh mogmarsh merged commit 4b9f2dd into develop Mar 7, 2024
7 checks passed
@mogmarsh mogmarsh deleted the feature/issue-142/add-option-pull-trending-posts branch March 7, 2024 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants