Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better sorting #795

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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