-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Wrong wiki count in Dropdown by type #7334
Comments
If we click on by Views button then it shows all 3 but again if try to sort all 3 of them by title it again shows 1 newsletter |
Can I try fix this? |
yes, you can try this but before doing this get it reviewed by @SidharthBansal @nstjean @jywarren |
Sure. Please provide a fix |
@gabrielbaldao are you doing this or can I proceed? |
Go ahead |
Note we should make this match the code and tests here: #7476 and the idea for a "single source of truth" here: #6855 (comment) Thank you! |
And noting a more detailed investigation here -- I think we need to be sure all counts are from a unified body of code maintained in the models, and unit tested! |
So we should confirm that all counts are coming from the respective And on tag cards, for example on https://publiclab.org/tags |
Just noting that the original issue at top may be a special case. I see in the DB that we're fetching these three pages:
Only the middle one is the correct one. The first may be some kind of strange clone... not sure. From the early days of the site? And the last, doesn't look like a page anymore? Here are the full records:
Very mysterious! |
Jeanette from PL noted this page also has an elevated number of wiki pages listed on the tab count: 83 is a much bigger error than what @keshavsethi had found, as only 6 wiki pages are shown. We can go into the database directly to just skim what those wiki pages actually are, in the query returning 86, and compare the queries too. |
OK! The disparity, for the
I'll look at the code behind them to confirm what's going on. Here is the tab count: plots2/app/controllers/tag_controller.rb Lines 542 to 561 in 92834ea
It references Lines 621 to 630 in 122e8a7
By contrast, Lines 94 to 116 in 122e8a7
Noting that the first 6 items on both https://publiclab.org/wiki/tag/method and https://publiclab.org/methods are the same, but /wiki/tag/method cuts off after 6. A clue? 🕵️ |
Both segments of code are significantly complicated by |
OK, so the difference is in the irb(main):010:0> Tag.find_nodes_by_type('method','page', false).count
=> 83
irb(main):011:0> Tag.find_nodes_by_type('method','page').count
=> 5 Let's track where the limit is being set on https://publiclab.org/wiki/tag/method But, a follow-up could be to consolidate this code and/or remove the |
So, the query for the listing of wiki pages in the table below on /wiki/tag/method is: plots2/app/controllers/tag_controller.rb Line 117 in 92834ea
I /believe/ none of these have parent tag issues, having checked in the db. So we're left with a strange mystery of pagination, which I can't quite figure out. Each of these pages show a different collection, with some overlapping items:
We can probably get all 83 pages this way. So it could be pagination being missing -- we could activate by adding plots2/app/views/wiki/_wikis.html.erb Line 30 in 92834ea
But there's something else -- why is |
Let's fix pagination, and then return here to see what we can do about the repeated display of some items, as well as figure out why page 1 shows only 6, but later pages show a full 24 (i think?)??? |
VERY strange -- #8243 (comment) --- pagination mysteries persist... |
OK, noting from this comment that the |
Indeed: > Node.for_tagname_and_type('method','page',question:false).paginate(page: 1,per_page: 24).order('node_revisions.timestamp DESC').length
=> 4 |
It seems to be the mix of irb(main):089:0> Node.for_tagname_and_type('method','page',question:false).paginate(page: 1,per_page: 24).order('node_revisions.timestamp DESC').length
=> 4
irb(main):090:0> Node.for_tagname_and_type('method','page',question:false).paginate(page: 1,per_page: 24).length
=> 24
irb(main):091:0> Node.for_tagname_and_type('method','page',question:false).order('node_revisions.timestamp DESC').paginate(page: 1,per_page: 24).length
=> 4 |
Lines 626 to 629 in f38bd54
|
I believe this may be an issue with our pagination library,
|
OK, we've installed |
Confirming that https://unstable.publiclab.org/wiki/tag/method now shows https://unstable.publiclab.org/wiki/tag/method?page=2, https://unstable.publiclab.org/wiki/tag/method?page=3, https://unstable.publiclab.org/wiki/tag/method?page=4 with all entries. That resolves this original issue (we should count the results to be sure) however, I now notice that, strangely, the first page lists only 4, while later pages show the full max per-page limit: |
OK, we are doing better... 32 are listed. But the total should be 83! 13 are listed per page, so if the first page were missing, say, 9 to make a full 13, we'd still only be at 41 total. Let me try to get a list of the full 83 to check discrepancies... |
Here are all 83:
|
OK - theory - just confirmed that the tag |
None from the 83. I'm going to try starting a development environment from staging and to try logging out the contents of the |
wow let's try this! https://ddnexus.github.io/pagy/how-to#custom-count-for-custom-scopes @pagy, @records = pagy(custom_scope, count: custom_count) |
also noting https://ddnexus.github.io/pagy/extras/arel |
OK, ready to try this in unstable with:
|
custom count didn't work w/ |
OK, found a deep inconsistency:
Whoa....
This totally doesn't match the displayed # of posts, which is:
|
OK, it appears that the wild pagination occurs when running:
but not:
so i propose that as a short-term fix. This will sort them by descending |
* rework order_by for #7334 * adjust sort dropdown text * rubocop/codeclimate formatting
* rework order_by for publiclab#7334 * adjust sort dropdown text * rubocop/codeclimate formatting
* rework order_by for publiclab#7334 * adjust sort dropdown text * rubocop/codeclimate formatting
* rework order_by for publiclab#7334 * adjust sort dropdown text * rubocop/codeclimate formatting
* rework order_by for publiclab#7334 * adjust sort dropdown text * rubocop/codeclimate formatting
* rework order_by for publiclab#7334 * adjust sort dropdown text * rubocop/codeclimate formatting
* rework order_by for publiclab#7334 * adjust sort dropdown text * rubocop/codeclimate formatting
* rework order_by for publiclab#7334 * adjust sort dropdown text * rubocop/codeclimate formatting
* rework order_by for publiclab#7334 * adjust sort dropdown text * rubocop/codeclimate formatting
In https://publiclab.org/contributors/newsletter dropdown by type Wiki pages is showing 3 but on clicking it shows only 1
![Screenshot from 2020-01-23 17-47-30](https://user-images.githubusercontent.com/36025262/72984149-0653bb80-3e09-11ea-91e5-5c905567f5a1.png)
Image is shown below
The text was updated successfully, but these errors were encountered: