class TriageQuery
Tables that need attention: the ones whose health is degraded. One row per table, most recently degraded first.
Constants
- BAD_HEALTH
- Row
Public Instance Methods
Source
# File app/queries/triage_query.rb, line 13 def call(limit: 50) rows = candidates.map { |table| build_row(table) } # NULLs sort last: with no known instant, it is not new information. rows.sort_by { |row| [ row.degraded_at.nil? ? 1 : 0, -(row.degraded_at&.to_i || 0) ] } .first(limit) end
Builds one row per degraded table, sorted by most recently degraded first (tables that entered a bad state long ago are pushed to the end), then truncates to the given limit. @param limit [Integer] the maximum number of rows to return. @return [Array<TriageQuery::Row>] the most recently degraded tables.