@crawl.v2_reports.select { |r| !r.reported_at.nil? }
sort_by { |r| r.reported_at.to_i }.
reverse.
uniq { |r| r.v2_report_template_id }
SELECT t.*
FROM
(SELECT reported_at, MAX(id) as id FROM v2_reports GROUP BY reported_at) a
INNER JOIN v2_reports t ON (t.id = a.id)
@crawl.v2_reports_dataset
.exclude(reported_at: nil)
.order("reported_at ASC")
.group(:v2_report_template_id)