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

Top Posts & Pages widget: applies filter post type choice filter after calculating total posts to display #2369

Closed
macmanx2 opened this issue Jul 7, 2015 · 40 comments
Labels
Customer Report Issues or PRs that were reported via Happiness. aka "Happiness Request", or "User Report" [Feature] Extra Sidebar Widgets [Feature] Stats Data Feature that enables users to track their site's traffic and gain insights on popular content. [Pri] High [Type] Bug When a feature is broken and / or not performing as intended

Comments

@macmanx2
Copy link
Contributor

macmanx2 commented Jul 7, 2015

The updated Top Posts & Pages widget from Jetpack 3.6 is applying the types choice after the total is collected, which in most cases results in a mismatch with the desired total. This is hard for me to explain with words, so how about an example? :)

http://macmanx.com/ has 1,276 Posts, with stats going back to the day Jetpack was first released, yet when I set my Top Posts & Pages widget to display my top 10 posts, it only displays 6. If I set it to display my top 10 posts and pages, it displays 10, and 4 of those are pages.

In the above example, rather than fetching my top 10 posts, the widget fetches my top 10 posts and pages, then filters out the 6 posts from that.

@macmanx2 macmanx2 added [Type] Bug When a feature is broken and / or not performing as intended [Feature] Extra Sidebar Widgets labels Jul 7, 2015
@kraftbj kraftbj added this to the 3.7 milestone Jul 7, 2015
@kraftbj
Copy link
Contributor

kraftbj commented Aug 12, 2015

One suggestion for this is to pull a higher number (whatever reasonable... 20, 50, etc), then filter them locally to return the specific number of posts or pages.

@kraftbj kraftbj changed the title Top Posts/Pages Widget Applies Post/Page Choice Filter *After* Total Top Posts/Pages Widget: Applies Post/Page Choice Filter *After* Total Aug 12, 2015
@zinigor zinigor modified the milestones: 3.7, 3.8 Aug 25, 2015
@samhotchkiss samhotchkiss modified the milestones: 3.8, Needs Triage Aug 28, 2015
@kraftbj
Copy link
Contributor

kraftbj commented Sep 11, 2015

Also noting that this would also be resolved by #2196, though my earlier suggestion would work depending on the timeline for the rewrite.

@kraftbj kraftbj added the [Feature] Stats Data Feature that enables users to track their site's traffic and gain insights on popular content. label Sep 11, 2015
@mediageni
Copy link

Top Posts & Pages (JetPack) stopped working, I had 10 posts displaying yesterday, now it's only showing one. What can be wrong?

@jeherve
Copy link
Member

jeherve commented Dec 13, 2015

@scriptgeni Can you please use Jetpack's Debugger module to send us some more information about your site?

  1. Go to the Jetpack page in your dashboard.
  2. Click on the Debug link appearing at the bottom of the page.
  3. Click the link that says "click here to contact Jetpack support."
  4. Fill in the description box and your name and email address.
  5. Click the "Contact Support" button.

Thanks!

@jeherve jeherve modified the milestones: 3.9, Needs Triage Dec 13, 2015
@atrus1701
Copy link
Contributor

I recently fixed the issue #2196 mentioned above. I can tell you that in resolving that issue, it did not fix this issue. This is due to the way Top Posts are retrieved from the server.

Issue 1:
The Top Posts endpoint on the REST API does not support filtering by post type. So if the widget is setup to view the top posts of a not-often-viewed custom post type, those posts might be low on the overall list. Meaning, it possibly could not show up on the retrieved list of 10 or so posts. You could try reconnecting and retrieving more posts, but it would be better to fix it on the server end, in my opinion.

Issue 2:
In addition, the REST endpoint restricts the max number of posts per day and doesn't retrieve an overall list of top posts. This probability won't affect most sites with the default option of top posts over 2 days, but if a site wants the top posts over a longer period, such as a month, this could allow a post that is visited more often over time to be cut off by posts that were only popular for a short time.

After looking through the public-api code, to fix the first issue would require a change to the select statement used to retrieve the list to something like SELECT from $pageviews_table JOIN $site_posts_table WHERE post_type IN ($post_types). However, for the second issue, the select statement is more complex with either a temp table or UNION ALL needed to collect a full list of posts. Of course, you could always run multiple select statements, merge the results, and filter using PHP as well. But I don't have the full view of how the database structure of WP.com is setup so there might be an easier way,

@jeherve jeherve modified the milestones: 4.0, 3.9 Jan 15, 2016
@jeherve
Copy link
Member

jeherve commented Mar 31, 2016

@csonnek
Copy link
Member

csonnek commented May 11, 2016

@jeherve jeherve modified the milestones: 4.1, 4.3 Jun 17, 2016
@richardmuscat richardmuscat removed this from the 4.3 milestone Jul 7, 2016
@samhotchkiss samhotchkiss modified the milestones: 4.4, Not Currently Planned Nov 9, 2016
@jeherve
Copy link
Member

jeherve commented Nov 15, 2016

@lancewillett lancewillett changed the title Top Posts/Pages Widget: Applies Post/Page Choice Filter *After* Total Top Posts & Pages widget: applies filter post type choice filter after calculating total posts to display Dec 28, 2016
@jeherve
Copy link
Member

jeherve commented Feb 13, 2017

@jeherve jeherve removed this from the Not Currently Planned milestone Mar 15, 2017
@lschuyler
Copy link

Reported in 3165769-t

@AndreaBarghigiani
Copy link

I really appreciate all the work that this community is doing in order to improve the plugin, but I have a doubt: is this issue fixed?

I am asking because as reading from here it should be fixed by the 4.4 version and now we're running the 5.1 but I still have the same problem.

I still have to try the fix proposed by @t22james from this topic on, but before I do it I would like to understand a bit more what is going on.

Can we help the team testing some code? Shall we use the solution already proposed?

I am asking because I think this is a bug that needs to be fixed because otherwise, we as developers will have a problem working with this widget, especially if we have clients that need some sort of "top post by category".

I already tried to load more posts and then filter them out, but it does not assure to have a fixed number of posts inside our list.

Sometime the list could be even empty and it's difficult to understand how to run a check to hide the title widget if the list is empty.

Thank you for your hard work and for the support as well.

Talk you soon,
Andrea

@jeherve
Copy link
Member

jeherve commented Sep 6, 2017

is this issue fixed?

No, this issue is still open, we don't have any perfect solution yet, so nothing for you to test either. We'll update this issue once we have some news!

@Ipstenu
Copy link

Ipstenu commented Nov 26, 2017

Yep, still an issue.

If Jetpack an detect the number of public post types, then why not just collect a number of posts (per the widget) and multiply it by the available post types.

So if I have posts, pages, and portfolios, and my widget is set to show the top 5, then it would collect 15 posts.

@jeherve
Copy link
Member

jeherve commented Mar 16, 2018

Related: 7973-wpcom

@tmmbecker
Copy link

tmmbecker commented Apr 6, 2018

also reported here 1006113-zen
1930-gh-jpop-issues

@jeherve
Copy link
Member

jeherve commented Feb 1, 2019

Another report in #11235 (cc @bsugerman)

@macmanx2
Copy link
Contributor Author

macmanx2 commented Jul 7, 2019

This appears to be a variation of this bug: https://wordpress.org/support/topic/bug-popular-posts-and-pages-widget/

@nardbyte
Copy link

nardbyte commented Jul 7, 2019

This appears to be a variation of this bug: https://wordpress.org/support/topic/bug-popular-posts-and-pages-widget/

Thanks for your reply, let me check the code, i go try fix it and i say here.

@darnelldibbles-zz
Copy link

@ntpixels
Copy link

ntpixels commented Nov 5, 2019

Also reported by 2471335-zen

@matticbot matticbot added the Customer Report Issues or PRs that were reported via Happiness. aka "Happiness Request", or "User Report" label Nov 5, 2019
@jeherve
Copy link
Member

jeherve commented Apr 9, 2020

This should be fixed as of #15109.

@jeherve jeherve closed this as completed Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Customer Report Issues or PRs that were reported via Happiness. aka "Happiness Request", or "User Report" [Feature] Extra Sidebar Widgets [Feature] Stats Data Feature that enables users to track their site's traffic and gain insights on popular content. [Pri] High [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

No branches or pull requests