Re-fetches from flickr

This commit is contained in:
Brenda Wallace
2018-02-05 11:49:39 +13:00
parent a69afd87e7
commit 88da0da616
3 changed files with 11 additions and 2 deletions

View File

@@ -88,7 +88,7 @@ class PhotosController < ApplicationController
photo = Photo.find_by(flickr_photo_id: flickr_photo_id_param)
photo ||= Photo.new(photo_params)
photo.owner_id = current_member.id
photo.set_flickr_metadata
photo.set_flickr_metadata!
photo
end

View File

@@ -50,7 +50,11 @@ class Photo < ActiveRecord::Base
end
end
def set_flickr_metadata
def set_flickr_metadata!
update_attributes(flickr_metadata)
end
def to_s
"#{title} by #{owner.login_name}"
end
end

View File

@@ -1,5 +1,10 @@
class AddDatetakenToPhotos < ActiveRecord::Migration
def change
add_column :photos, :date_taken, :datetime
# Fetch from flickr, the photos updated the longest ago will be fetched first
Photo.all.order(:updated_at).each do |photo|
say "Fetch flickr data for #{photo}"
photo.set_flickr_metadata!
end
end
end