Skip to content

Commit

Permalink
better sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Aug 24, 2023
1 parent 0613501 commit ab5e324
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/controllers/api/v1/cases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ def index
elsif sort_by
current_user.cases_involved_with.preload( :tries).not_archived.order(sort_by)
else
current_user.cases_involved_with.preload(:tries, :teams, :cases_teams).not_archived
current_user.cases_involved_with.preload(:tries, :teams,
:cases_teams)
.not_archived
.left_outer_joins(:metadata)
.order(Arel.sql('`case_metadata`.`last_viewed_at` DESC, `cases`.`updated_at` DESC'))
end
end

Expand Down
4 changes: 4 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

class HomeController < ApplicationController
# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/MethodLength
def show
# @cases = @current_user.cases.not_archived.includes([ :scores ])
@cases = @current_user.cases.not_archived
.left_outer_joins(:metadata)
.order(Arel.sql('`case_metadata`.`last_viewed_at` DESC, `cases`.`updated_at` DESC'))

# copied from dropdown_contoller.rb
@most_recent_cases = lookup_most_recent_cases
Expand All @@ -26,6 +29,7 @@ def show
@grouped_cases = @grouped_cases.select { |_key, value| value.count > 1 }
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/MethodLength

private

Expand Down

0 comments on commit ab5e324

Please sign in to comment.