Skip to content

Commit

Permalink
FIXED: flickr photos were not being cached
Browse files Browse the repository at this point in the history
  • Loading branch information
captproton committed Oct 9, 2017
1 parent cdff10a commit 259311e
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions app/models/flickr_photo_collector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ def all
def cache_photos(photo_collection)
photos = photo_collection.flatten
photos.each do |photo|
#move "id" to "flickr_id"
photo.flickr_id = photo.id.to_s
photo.delete_field("id")
# convert from 0/1 to boolean
photo.ispublic = to_boolean(photo.ispublic)
photo.isfriend = to_boolean(photo.isfriend)
photo.isfamily = to_boolean(photo.isfamily)
self.prepare_attributes_for_storage(photo)
hotel_photo = CachedFlickrPhoto.find_or_create_by(flickr_id: photo.flickr_id)
hotel_photo.update(photo.to_h)
end
Expand All @@ -42,9 +36,9 @@ def prepare_attributes_for_storage(photo)
photo.flickr_id = photo.id.to_s
photo.delete_field("id")
# convert from 0/1 to boolean
photo.ispublic = to_boolean(photo.ispublic)
photo.isfriend = to_boolean(photo.isfriend)
photo.isfamily = to_boolean(photo.isfamily)
photo.ispublic = self.to_boolean(photo.ispublic)
photo.isfriend = self.to_boolean(photo.isfriend)
photo.isfamily = self.to_boolean(photo.isfamily)
end

def to_boolean(value)
Expand Down

0 comments on commit 259311e

Please sign in to comment.