Plots2: Wiki Pages can't be sorted by the pageviews

Created on 8 Jan 2018  路  7Comments  路  Source: publiclab/plots2

Please describe the problem (or idea)

Wiki pages do not get sorted in the descending order on https://publiclab.org/wiki/popular
image

bug in-progress

All 7 comments

I think it is due to the .order('views DESC') instead of .order('node.views DESC')
https://github.com/publiclab/plots2/blob/646deeb659cd62064792b4134155717d08a5b5a5/app/controllers/wiki_controller.rb#L309-L318
@jwarren Shall I make a pr for it?

Sure, can you confirm your fix in local testing? Thank you!

Is it due to the issue #1196 ?I guess the error is in the "totalviews". I changed the value of the "views" from the console but the /wiki/popular shows no added number of "pageviews". I tried to change "totalviews" to "views" in the app/views/wiki/_wikis and then it was showing output according to the values of "views" set by the rails console

Hmm, I'm not sure. Can you look for where we increment the view count? It would be under either the wiki controller or potentially a model method in node.rb -- maybe we can diagnose that way. Thanks!!

Yeah under node.rb, total views is given and it points to issue#1196. Impressionist gem is not working properly since then.

Hmm, but it looks like totalviews is actually incrementing -- visit any recent post and there are counted views -- maybe that comment is out of date? I think impressionist must be working. But totalviews is from another table, since that's how Impressionist works. I think we have to look on stack overflow or under the Impressionist docs for how to sort by an impressionist-tracked view count?

I updated #1196 to specify that the broken part is just the caching of the tally of views, not that the tallying is not happening at all. Hope that helps!

Thanks, your hints always works :smile:
image
It is working now.
The error was in the controller we are sorting by node.views and the view we are displaying the node. totalviews where totalviews is a node model method.
So, I just changed the controller to sort according to the totalviews model method by sort_by function.
Order cannot be used as we dont have any totalviews column in any database table.
Just attaching the pr in a few minutes
Thanks

Was this page helpful?
0 / 5 - 0 ratings