mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-03-23 17:22:24 -04:00
Re-fetches from flickr
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user