Skip to content

Commit

Permalink
fix: Change order by sort_by to avoid sorting by weight
Browse files Browse the repository at this point in the history
  • Loading branch information
AyakorK committed Mar 11, 2024
1 parent 7ff4492 commit 8c3c28c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/controllers/decidim/assemblies/assemblies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def assembly_participatory_processes
assembly_participatory_processes = @current_participatory_space.linked_participatory_space_resources(:participatory_processes, "included_participatory_processes")

sorted_by_date = {
active: assembly_participatory_processes.active_spaces.order(end_date: :asc),
future: assembly_participatory_processes.future_spaces.order(start_date: :asc),
past: assembly_participatory_processes.past_spaces.order(end_date: :desc)
active: assembly_participatory_processes.active_spaces.sort_by(&:end_date).reverse,
future: assembly_participatory_processes.future_spaces.sort_by(&:start_date),
past: assembly_participatory_processes.past_spaces.sort_by(&:end_date).reverse
}

@assembly_participatory_processes ||= sorted_by_date
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/assemblies_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ module Assemblies

it "includes only participatory processes related to the assembly, actives one by end_date then upcoming ones by start_date then past ones by end_date reversed" do
sorted_participatory_processes = {
active: participatory_processes.select(&:active?).sort_by(&:end_date),
active: participatory_processes.select(&:active?).sort_by(&:end_date).reverse,
future: participatory_processes.select(&:upcoming?).sort_by(&:start_date),
past: participatory_processes.select(&:past?).sort_by(&:end_date).reverse
}
Expand Down

0 comments on commit 8c3c28c

Please sign in to comment.