From 6fb5f04e900cbd51998621f277aedac4d243215e Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Sun, 6 May 2018 14:31:07 -0300 Subject: [PATCH] And even more generic --- app/models/dunlop/source_file_model.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/dunlop/source_file_model.rb b/app/models/dunlop/source_file_model.rb index b9095ef..2852b17 100644 --- a/app/models/dunlop/source_file_model.rb +++ b/app/models/dunlop/source_file_model.rb @@ -179,8 +179,8 @@ module Dunlop::SourceFileModel # braindump towards state => processed support for source-files def latest_processed - if base_class == self - join_select = processed.select('MAX(id) AS max_id').group(:sti_type) + if base_class == self # return a scope having only the latest processed source-files + join_select = processed.select('MAX(id) AS max_id').group(inheritance_column) #join_select = processed.selecting{ id.maximum.as('max_id')}.group(:sti_type) joins("INNER JOIN (#{join_select.to_sql}) tmp ON id = tmp.max_id") else # return the latest process of the specific source-file class