-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Iagirre budget pagination bug #2131
Merged
voodoorai2000
merged 5 commits into
consuldemocracy:master
from
wairbut-m2c:iagirre-budget-pagination-bug
Nov 27, 2017
Merged
Iagirre budget pagination bug #2131
voodoorai2000
merged 5 commits into
consuldemocracy:master
from
wairbut-m2c:iagirre-budget-pagination-bug
Nov 27, 2017
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…dom order used. Scope variable initialized to 1
Awesome @iagirre! 👌 |
This was referenced Nov 27, 2017
voodoorai2000
added a commit
to AyuntamientoMadrid/consul
that referenced
this pull request
Mar 1, 2018
We are trying out a modulus function to return investments in random order consuldemocracy#2131 However we ran into the gotcha of having a seed value too big for the modulus function to work as expected If the seed is bigger than the investment id, the records are returned ordered by id By dividing the seed by a big number, this problem seems to get fixed
voodoorai2000
added a commit
to AyuntamientoMadrid/consul
that referenced
this pull request
Mar 1, 2018
This is a defensive test, just in case we decide to go back to using `setseed` instead of the `modulus`[1] approach to display investments in random order The reason for this test is that `setseed` only ~works in the next `select` statement. And as when loading a user’s votes for investments we do a second `select` it does not work as expected 😌 To solve this… we could call `set_random_seed` before loading a user’s votes for an investment[2] [1] consuldemocracy#2131 [2] https://github.com/AyuntamientoMadrid/consul/blob/master/app/controllers /budgets/investments_controller.rb#L37
voodoorai2000
added a commit
that referenced
this pull request
Apr 5, 2018
We are trying out a modulus function to return investments in random order #2131 However we ran into the gotcha of having a seed value too big for the modulus function to work as expected If the seed is bigger than the investment id, the records are returned ordered by id By dividing the seed by a big number, this problem seems to get fixed
voodoorai2000
added a commit
that referenced
this pull request
Apr 5, 2018
This is a defensive test, just in case we decide to go back to using `setseed` instead of the `modulus`[1] approach to display investments in random order The reason for this test is that `setseed` only ~works in the next `select` statement. And as when loading a user’s votes for investments we do a second `select` it does not work as expected 😌 To solve this… we could call `set_random_seed` before loading a user’s votes for an investment[2] [1] #2131 [2] https://github.com/AyuntamientoMadrid/consul/blob/master/app/controllers /budgets/investments_controller.rb#L37
clairezed
pushed a commit
to CDJ11/CDJ
that referenced
this pull request
Jun 26, 2018
…et-pagination-bug Iagirre budget pagination bug
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Where
What
There was a bug when a user navigates from one investment page to another. This bug repeated the investmentes between pages, and there where other investments that didn't appear.
e.g. Page 1 contains 4, 7, 2, 8, 3; Page 2 contains 7, 4, 1 -> 5 and 6 are missing, because 4 and 7 are repeated.
How
I followed this Stackoverflow answer to make a semi-random order (it's not a real random selection, but it makes what we want for this case), because I detected that using
random()
(event if we use PostgreSQLsetseed
to set a seed) is not maintaining the order from the variable we get on controller and the one used in the view (the variable in theeach
loop. Something that may be involved). I think that this is the problem with repeating objects between pages.Screenshots
Nothing to show.
Test
Deployment
Nothing to apply.
Warnings
Nothing to apply
As a side note
I changed the test from Madrid's fork slighly to check the order when the user navigates through pages, instead of visiting the
budget_investments_path
again. As I understood, the order should be maintained when users change the page, not when they revisit it (talking about random order).