Remove useless increment when creating a new board list
This commit is contained in:
parent
847ebce90a
commit
d8fc783bb9
1 changed files with 2 additions and 9 deletions
|
@ -3,15 +3,13 @@ module Boards
|
|||
class CreateService < Boards::BaseService
|
||||
def execute
|
||||
List.transaction do
|
||||
position = find_next_position
|
||||
increment_higher_lists(position)
|
||||
create_list_at(position)
|
||||
create_list_at(next_position)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_next_position
|
||||
def next_position
|
||||
max_position = board.lists.label.maximum(:position)
|
||||
max_position.nil? ? 0 : max_position.succ
|
||||
end
|
||||
|
@ -19,11 +17,6 @@ module Boards
|
|||
def create_list_at(position)
|
||||
board.lists.create(params.merge(list_type: :label, position: position))
|
||||
end
|
||||
|
||||
def increment_higher_lists(position)
|
||||
board.lists.label.where('position >= ?', position)
|
||||
.update_all('position = position + 1')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue