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

Reordering large lists is slow #198

Closed aaroncraigongithub closed 8 years ago

aaroncraigongithub commented 8 years ago

On a large list, something like move_to_top will trigger changes on every item in the list, which seems like overkill in most use cases.

If the :position field is a float, wouldn't it be easier to leverage more granularity in the position value so that moving an item in the list would affect only that single item?

That is, if my current list positions are 1, 2, 3 and I move 3 to the top, my new state could be 0.99, 1, 2, leaving the other two items in the list untouched.

I'm happy to work on a PR for this if it seems like something that would be acceptable.

brendon commented 8 years ago

Hi @aaroncraigongithub, in my applications position is an integer. I think most developers do it that way. I guess you could have a detection of the type and act appropriately.

However, what I think you want is this: https://github.com/mixonic/ranked-model

Unfortunately it looks like it's dead (or hibernating!) which is a shame because I've used it in one of my projects too.

brendon commented 8 years ago

@aaroncraigongithub, I'm going to close this for now. Feel free to continue the discussion here though.

raimo commented 8 years ago

This is a really weird situation we have here – very sad ranked-model is not maintained. :)

Probably a cool project for someone to create a partial fork of both.