Class: PageLinkJob
- Inherits:
-
Struct
- Object
- Struct
- PageLinkJob
- Defined in:
- app/jobs/page_link_job.rb
Instance Attribute Summary collapse
-
#system_id ⇒ Object
Returns the value of attribute system_id.
Instance Method Summary collapse
Instance Attribute Details
#system_id ⇒ Object
Returns the value of attribute system_id
1 2 3 |
# File 'app/jobs/page_link_job.rb', line 1 def system_id @system_id end |
Instance Method Details
#error(job, e) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'app/jobs/page_link_job.rb', line 18 def error(job, e) Preference.set(system_id, "last_crawl", nil) notes = [] notes << "Exception Message: #{e.}" notes << "Stack Trace: #{e.backtrace.join("\n")}" reference = Digest::MD5.hexdigest(Time.now.to_s)[0..8] Event.store("PageLinkJob error", nil, 0, notes.join("\n"), reference) Activity.add(system_id, "Page Link refresh Failed #{reference}", 0, "System", '') Rails.logger.error "PageLinkJob error: #{reference} #{e.}" end |
#perform ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/jobs/page_link_job.rb', line 3 def perform last_crawl = (Time.zone.parse(Preference.get(system_id, "last_crawl")) rescue nil) this_crawl = Time.now Preference.set(system_id, "last_crawl", this_crawl) Rails.logger.debug "Last crawl #{last_crawl} This Crawl #{this_crawl}" pages = Page pages = pages.sys(system_id) unless system_id == 0 pages = pages.where(["needs_crawl > ?", last_crawl]) if last_crawl pages = pages.where(["needs_crawl <= ?", this_crawl]) pages.where("needs_crawl is not null").find_each do |p| Rails.logger.debug "Crawling page #{p.id}" p.crawl end end |