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