brendon / acts_as_list

An ActiveRecord plugin for managing lists.
http://brendon.github.io/acts_as_list/
MIT License
2.04k stars 355 forks source link

Added Functionality for Repairing Duplicate Positions in List #335

Closed pacarvalho closed 3 months ago

pacarvalho commented 5 years ago

closes #333

pacarvalho commented 5 years ago

@brendon I am still working on this PR but I put it here so that you can have a look and let me know if this is what you had in mind.

I still need to write the functions and checks for gaps in the list, improve tests and write documentation.

I might also add a protection to impede the function from getting stuck in the while look... Just not sure if it makes sense...

brendon commented 5 years ago

I'm still interested in adding this. Also see https://github.com/swanandp/acts_as_list/pull/284/files which I've closed but had a test for detecting corrupted lists. Perhaps we could add an auto-correct option (off by default)?

oyeanuj commented 4 years ago

@pacarvalho Is this still on your radar?

pacarvalho commented 4 years ago

@oyeanuj I am interested in seeing this completed. Just need to know what needs to be changed/added. It has been a while since I started this so I don't quite remember where we left off :/

Are you interested in collaborating?

brendon commented 4 years ago

I'm happy to review what you guys come up with. I think the overarching goal of any auto-correction would be for it to be completely transparent to the user (and with no side effects). Since it'll likely happen at the time a change is being made to the list, this could get messy as if positions of items change from what the user was expecting, their intentions could become invalid.

I might have the wrong end of the stick however, it's been a long time since I looked at this :D

oyeanuj commented 4 years ago

@brendon @pacarvalho Thanks for the quick responses! I honestly don't understand the code enough (or for that matter Rails), to be able to come up with a sufficiently competent PR. Mostly, I was curious if I should be expecting this PR to this library or not :)

brendon commented 3 months ago

Closing this as it's been 4 years. Check out https://github.com/brendon/positioning as an alternative that does its best to avoid list corruption. It works with database uniqueness constraints and advisory locks to prevent these kinds of issues.