Created
August 29, 2012 18:44
-
-
Save flsafe/3516948 to your computer and use it in GitHub Desktop.
refresh ads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pdfs=[ | |
"864546-01.pdf", | |
"869017-01.pdf", | |
"869017-01.pdf", | |
"867131-01.pdf", | |
"867131-01.pdf", | |
"865896-01.pdf", | |
"865896-01.pdf", | |
"863510-01.pdf", | |
"863510-01.pdf", | |
"864049-01.pdf", | |
"864049-01.pdf", | |
"864049-01.pdf", | |
"866812-01.pdf", | |
"869020-01.pdf", | |
"864339-01.pdf", | |
"864339-01.pdf", | |
"868066-01.pdf", | |
"865582-01.pdf", | |
"873716-01.pdf", | |
"868111-01.pdf", | |
"865274-01.pdf", | |
"865274-01.pdf", | |
"868143-01.pdf", | |
"868143-01.pdf", | |
"865613-01.pdf", | |
"864372-01.pdf", | |
"864372-01.pdf", | |
"863585-01.pdf", | |
"863585-01.pdf", | |
"867236-02.pdf", | |
"867236-02.pdf", | |
"869357-01.pdf", | |
"870748-01.pdf", | |
"868082-01.pdf", | |
"859763-01.pdf", | |
"863797-01.pdf", | |
"873394-01.pdf", | |
"869035-01.pdf", | |
"866880-01.pdf", | |
"867262-01.pdf"] | |
pe = Publisher.first(:name => 'The Press-Enterprise') | |
raise "No publisher PE" if pe.nil? | |
businesses = Ad.all(:pdf_file_name=>pdfs).map(&:business).uniq | |
raise "No businesses with pdf_file_names found" if businesses.empty? | |
raise "Unexpected businesses" unless businesses.all?{|b|b.publisher == pe} | |
businesses.each do |b| | |
ad = b.ads.last | |
ad.start_date = Date.today | |
ad.end_date = Date.today+7.days | |
unless ad.save | |
raise "Could not refresh last ad for business #{b.name}: #{ad.errors.full_messages}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment