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).