Forked from apsheronets/gist:89e55165e70b3013e5e2
Last active
August 29, 2015 14:04
-
-
Save Voker57/f18f400dfdd12e068f5b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Komariq | |
def self.update_entries(criteria, action) | |
while true | |
needs_update = criteria.call | |
count = needs_update.count | |
if count > 0 | |
Rails.logger.info "#{count} feeds need to be updated" | |
needs_update.each do |entry| | |
begin | |
Rails.logger.info "Feed #{feed.id} is going to be updated" | |
start = Time.now | |
action.call entry | |
finish = Time.now | |
time = finish - start | |
Rails.logger.info "Feed #{feed.id} updated in #{time} seconds" | |
rescue => e | |
Rails.logger.info e.message | |
Rails.logger.info e.backtrace.join("\n") | |
end | |
end | |
else | |
sleep 30 | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment