Class: Tjcrawler::Page

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/tjcrawler/page.rb

Constant Summary collapse

@@semaphore =
Mutex.new

Class Method Summary collapse

Class Method Details

.dequeueObject



13
14
15
# File 'lib/tjcrawler/page.rb', line 13

def dequeue
  Page.where('crawled_at IS NULL OR crawled_at < ?', 1.day.ago).order('crawled_at IS NOT NULL, crawled_at').first
end

.enqueue(url) ⇒ Object



9
10
11
# File 'lib/tjcrawler/page.rb', line 9

def enqueue url
  @@semaphore.synchronize{Page.find_or_create_by url: url}
end