Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.54 KB | None | 0 0
  1. if ad_insertion[:rundate_insert] == nil or ad_insertion[:rundate_insert] then
  2.             # if ad_insertion[:rundate_insert] != false && !ad_insertion[:kill_all]
  3.                 if ad_insertion[:location].nil?
  4.                     existing_rundate = AutomatorAdRundate.find(:first, :conditions=>["UPPER(ad_num)=? and rundate=? and UPPER(pub_code)=?", ad_insertion[:ad_num].upcase, Date.strptime(ad_insertion[:rundate], '%m/%d/%Y'), ad_insertion[:pubcode].upcase])
  5.                 else
  6.                     existing_rundate = AutomatorAdRundate.find(:first, :conditions=>["UPPER(ad_num)=? and rundate=? and UPPER(pub_code)=? and UPPER(location)=?", ad_insertion[:ad_num].upcase, Date.strptime(ad_insertion[:rundate], '%m/%d/%Y'), ad_insertion[:pubcode].upcase, ad_insertion[:location].upcase])
  7.                 end
  8.                
  9.                 if existing_rundate == nil then
  10.                     new_rundate = AutomatorAdRundate.new
  11.                     new_rundate.ad_num = ad_insertion[:ad_num].upcase
  12.                     new_rundate.pub_code = ad_insertion[:pubcode].upcase
  13.                     new_rundate.rundate = Date.strptime(ad_insertion[:rundate], '%m/%d/%Y')
  14.                     new_rundate.created_at = Time.now
  15.                     new_rundate.status = ad_status
  16.                     new_rundate.location = ad_insertion[:location].nil? ? "" : ad_insertion[:location].upcase
  17.                     new_rundate.desired_section = ad_insertion[:section]
  18.  
  19.                     if export_to_suite?
  20.                         new_rundate.other = ad_insertion[:other]
  21.                     end
  22.  
  23.                     new_rundate.save
  24.                 else
  25.                     existing_rundate.updated_at = Time.now if ad_insertion[:killed]
  26.                     if ad_insertion[:killed] then
  27.                         existing_rundate.status = ad_status
  28.                     end
  29.                     existing_rundate.save
  30.                 end
  31.             end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement