class DailyRep::Entities::Doujob
Attributes
diff[R]
Public Class Methods
create()
click to toggle source
# File lib/dailyrep/entities/Doujob.rb, line 11 def self.create result = [] result = Configer.get_search_strs('doujob').map { |str| new str } end
new(search, source=Configer.doujob_source)
click to toggle source
Calls superclass method
DailyRep::IBrowser::new
# File lib/dailyrep/entities/Doujob.rb, line 18 def initialize search, source=Configer.doujob_source super @search=search.gsub(' ','+') @dou_search_path = source + @search @vacancy_scope = 'div#vacancyListId li' @parameter = 'title-href' @diff =[] end
Public Instance Methods
log_msg(phase)
click to toggle source
Calls superclass method
DailyRep::Trackable#log_msg
# File lib/dailyrep/entities/Doujob.rb, line 27 def log_msg phase super @entity, @search, phase end
notify()
click to toggle source
overwriting
Calls superclass method
# File lib/dailyrep/entities/Doujob.rb, line 47 def notify super do @diff.each { |lv1| push_note("New vacancy at DOU: #{lv1[2]} - #{lv1[3]} ") if lv1[0] == "-" push_note("DOU vacancy has gone: #{lv1[2]} - #{lv1[3]} ") if lv1[0] == "+" } end end
process()
click to toggle source
overwriting
Calls superclass method
# File lib/dailyrep/entities/Doujob.rb, line 32 def process super do out_set = get_source_http @dou_search_path, @vacancy_scope @out_vac = out_set.map do |a| [a.css('.title .vt').attribute("href").text, "#{a.css('.company').text} : #{a.css('.title .vt').text}"] end out_hash = @out_vac.map { |el| {el[0] => el[1]} } hist_hash = read_hist_hash @diff = HashDiff.diff(out_hash, hist_hash) end end
web_reload()
click to toggle source
overwriting
Calls superclass method
# File lib/dailyrep/entities/Doujob.rb, line 64 def web_reload super do set_html_with_diff @entity, '#doujobs', @diff end end
write_to_db()
click to toggle source
overwriting
Calls superclass method
# File lib/dailyrep/entities/Doujob.rb, line 56 def write_to_db super do @out_vac.each { |vac| write_hist @entity, @parameter, "#{vac[0]}=>#{vac[1]}" } end end
Private Instance Methods
read_hist_hash()
click to toggle source
# File lib/dailyrep/entities/Doujob.rb, line 71 def read_hist_hash maxtime = History.where(entity: @entity, parameter: @parameter).where("created_at > ?", Time.now - 6.hours).maximum("created_at") maxtime||= Time.now maxtime = maxtime.to_datetime History.select("val").where(entity: @entity, parameter: @parameter).where("created_at > ?", maxtime - 1.minute).map { |row| el_ar = row.val.split('=>') {el_ar[0] => el_ar[1]} } end