Skip to content

Commit

Permalink
Move timeout query to dedicated scope method
Browse files Browse the repository at this point in the history
  • Loading branch information
carbonin committed Dec 10, 2019
1 parent 1562a76 commit ecc9b73
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/miq_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,12 @@ def check_for_timeout(log_prefix = "MIQ(MiqQueue.check_for_timeout)", grace = 10
end
end

def self.candidates_for_timeout
where(:state => STATE_DEQUEUE).where("(select date_part('epoch', updated_on) + msg_timeout) < ?", Time.now.to_i)
end

def self.check_for_timeout
where(:state => STATE_DEQUEUE).where("(select date_part('epoch', updated_on) + msg_timeout) < ?", Time.now.to_i).each(&:check_for_timeout)
candidates_for_timeout.each(&:check_for_timeout)
end

def finished?
Expand Down

0 comments on commit ecc9b73

Please sign in to comment.