Skip to content

Commit 39b018e

Browse files
committed
Preserve status column order from previous board
`Status.where(id:)` does not preserve the order of the input IDs. Extracts `statuses_in_order` to look up statuses by ID and return them in the widget column order from the previous sprint board.
1 parent 32c68b2 commit 39b018e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

modules/boards/app/services/boards/sprint_task_board_create_service.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@ def statuses_from_last_sprint_board
8888
.sort_by(&:start_column)
8989
.filter_map { |w| w.options.dig("filters", 0, "status_id", "values")&.first }
9090

91-
Status.where(id: status_ids) if status_ids.present?
91+
statuses_in_order(status_ids) if status_ids.present?
92+
end
93+
94+
def statuses_in_order(status_ids)
95+
statuses_by_id = Status.where(id: status_ids).index_by(&:id)
96+
status_ids.filter_map { |id| statuses_by_id[id.to_i] }
9297
end
9398

9499
def statuses_from_sprint_work_packages

0 commit comments

Comments
 (0)