Skip to content

Commit

Permalink
Fix the error index SQL
Browse files Browse the repository at this point in the history
  • Loading branch information
fractaledmind committed Jan 15, 2024
1 parent ef0d37f commit 7bf5295
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions app/controllers/solid_errors/errors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ class ErrorsController < ApplicationController
def index
errors_table = Error.arel_table
occurrences_table = Occurrence.arel_table
recent_occurrence = occurrences_table
.project(occurrences_table[:created_at].maximum)
.as('recent_occurrence')

@errors = Error.unresolved
.joins(:occurrences)
.select(errors_table[Arel.star], recent_occurrence)
.select(errors_table[Arel.star], occurrences_table[:created_at].maximum.as('recent_occurrence'))
.group(errors_table[:id])
.order(recent_occurrence: :desc)
end
Expand Down

0 comments on commit 7bf5295

Please sign in to comment.