pings = DonPing.find(:all, :conditions => ["counter = 0 OR (counter < 10 AND created_at + INTERVAL '?' * POW(2, counter) SECOND < NOW() AND ( send_at IS NULL OR NOT status = 'success' ))", @defer_seconds],
:limit => @numbers,
:order => "id DESC"
)
else
pings = DonPing.find(:all, :conditions => ["send_at IS NULL OR NOT status = 'success'"],
:limit => @numbers,
:order => "id DESC"
)
end
puts 'Number of ping(s) is ' + pings.length.to_s if @verbose