adding list item with position not in sequence messes the existing list item positions
WaQasRPL opened this issue · 1 comments
i have a excel importer where the position is defined in one of the column to be imported, each excel row is imported in its own sidekiq job, although the jobs are started in sequence but there is no guarantee they will also be executed in same sequence due to different checks and conditions. here is an example excel sample
column1,column2,position,column3
XYZ2,ABC2,2,TUV2
XYZ1,ABC1,1,TUV1
XYZ3,ABC3,3,TUV3
then i am assigning the position to my list item as follows
parent.children.new(position: row[:position])
if the row jobs are executed in 1 , 2, 3 order then all good, but if for instance lets say 3 is executed before 2 so its sets the correct position which is 3 but upon completion of job 2 it increments the position 3, so i end up 1, 2 and 4 positions. it seems like a bug, i think it should only increment the current position if it exists.
i have tried different configuration like add_new_at, :top, :bottom but getting same result. it works only if i temporarily disable the acts_as_list by using no_update.