Skip to content

Conversation

@ollym
Copy link

@ollym ollym commented Dec 26, 2025

Thanks for the gem. We wanted to introduce repositioning code that allows for bulk changes to the position that would also take care of position conflicts during the bulk reordering.

  • add update_<column>_in_order_of! for bulk reordering by id list or weight hash
  • refactor healer to support bulk repositioning and scoped normalization
  • document Rails 7.1+ deferred unique keys and bulk reposition usage

Made sense to make it part of the "Healer" as they perform similar functionality.

@ollym
Copy link
Author

ollym commented Dec 28, 2025

I've just added partial repositioning which again we needed in our implementation, so like:

# positions: A:1, B:2, C:3, D:4, E:5
Item.update_position_in_order_of!([d.id, b.id])
# positions: A:1, D:2, C:3, B:4, E:5

@brendon
Copy link
Owner

brendon commented Dec 28, 2025

Hi @ollym, thanks for this. Just letting you know I’m away on holiday at the moment but will look at this when I return :) Hope that’s ok? :)

@ollym
Copy link
Author

ollym commented Dec 30, 2025

@brendon tests pass for me locally, so unclear why it's not working on CI

$ DB=postgresql rake test
Run options: --seed 61593

# Running:

....................................................................................................................................................................................

Finished in 6.854978s, 26.2583 runs/s, 460.1036 assertions/s.

180 runs, 3154 assertions, 0 failures, 0 errors, 0 skips

@brendon
Copy link
Owner

brendon commented Jan 1, 2026

Looks like something to do with composite primary keys? Will have a closer look when I get back :)

@brendon
Copy link
Owner

brendon commented Jan 5, 2026

Got the tests running. Might look at cherrypicking those commits into main and then will review this code in a week or so :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants