less is more
This commit is contained in:
@@ -181,15 +181,16 @@ module Dunlop::SourceFileModel
|
||||
def latest_processed
|
||||
if base_class == self
|
||||
join_select = processed.select('MAX(id) AS max_id').group(:sti_type)
|
||||
#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
|
||||
# 2 query based solution, probably faster than the one (sub) query solution
|
||||
processed.find_by(id: processed.maximum(:id))
|
||||
find_by(id: processed.maximum(:id))
|
||||
|
||||
## ONE QUERY SOLUTIONS
|
||||
# processed.find_by(id: processed.select('MAX(id)'))
|
||||
# find_by(id: processed.select('MAX(id)'))
|
||||
# OR using baby squeel
|
||||
# processed.find_by(id: processed.selecting{ id.maximum })
|
||||
# find_by(id: processed.selecting{ id.maximum })
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user