Class: Flightdeck::GroupedFailures
- Inherits:
-
Object
- Object
- Flightdeck::GroupedFailures
- Defined in:
- app/models/flightdeck/grouped_failures.rb
Overview
Groups the failed rows of the current page by exception class.
Grouping happens in Ruby on purpose. Extracting the exception class in SQL would mean a JSON function per adapter (and an unindexed scan of a large text column either way), which is a bad trade for a header row.
Defined Under Namespace
Classes: Group
Class Method Summary collapse
Class Method Details
.build(rows) ⇒ Object
17 18 19 20 21 22 |
# File 'app/models/flightdeck/grouped_failures.rb', line 17 def self.build(rows) rows .group_by { |row| row.error_summary.group_key } .map { |key, grouped| Group.new(key: key, rows: grouped) } .sort_by { |group| [ -group.count, group.key ] } end |