-
-
Notifications
You must be signed in to change notification settings - Fork 134
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 attribute update #86
Comments
@tommy-dev ranked-model gets its efficiency gain by not managing position, but instead only providing relative rankings in a large integer space. There is no guarantee there will not be a gap in the ranking. This should be spelled out pretty clearly at the top of the Readme. It seems here that your ranking column (ranks, not positions) is very tightly clustered. That means a rank rebalance is happening on every change. This is definitely not optimal, maybe this is coming from old data in a position column? Also, please upload an image without emails addresses, names and phone number. |
Here is my implementation, based on the readme: And dont worry about the images, data is Faker generated so no real personal data is shown here. :) |
@tommy-dev I remain very uncertain as to what you are trying to do. ranked models stores a rank in the database. You should not manually be setting the rank. It provides a position attribute (explained on the readme) for reading the position, but this is merely a convenience. If something is awry, a test or example code would help me understand what you are expecting to happen. |
There was a bug that may have caused this. It was fixed a long time ago. |
This is very nice gem, but has a liitle bug. Attribute used for ranking is wrongly updated. I found this when implementing some sortable tables in rails. List of users is ordered by position - attribute use by ranked-model. Here is how the table look like:
After taking element with position 15 to 5 every element gets updated, but look what happened to element with position > 15, it gets also added 1 so now there is a break (17th element after 15th, no element with position 16).
After some modification of order it gets really annoying, because you dont know exactly how its going to work.
Another mistake is that it doesnt work for two elements at all. Position is getting max integer and min integer value.
I am using Postgres with Rails 4, if you want to see my implementation I can add link to the project.
The text was updated successfully, but these errors were encountered: