Class: Tjcrawler::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Tjcrawler::Page
- Defined in:
- lib/tjcrawler/page.rb
Constant Summary collapse
- @@semaphore =
Mutex.new
Class Method Summary collapse
Class Method Details
.dequeue ⇒ Object
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 |