-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CHANGED: orientation to landscape. lickr photos were originally portr…
…ait, but the better photos are landscape.
- Loading branch information
1 parent
8265a61
commit 4d9be4a
Showing
9 changed files
with
60 additions
and
19 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,25 @@ | ||
class CachedFlickrPhotoSize < ActiveRecord::Base | ||
belongs_to :cached_flickr_photo | ||
|
||
scope :missing_ratio, -> { where(width_by_height: nil) } | ||
scope :last_week, lambda { where("created_at < ?", Time.zone.now ) } | ||
scope :portrait, lambda { where("width_by_height < ?", 1 ) } | ||
scope :landscape, lambda { where("width_by_height > ?", 1 ) } | ||
scope :medium, lambda { where(width_by_height: (1.3..1.4)) } | ||
|
||
def self.add_width_height_ratio_to_sizes_missing_ratio | ||
sizes = self.missing_ratio | ||
sizes.each do |size| | ||
self.add_width_height_ratio(size) | ||
end | ||
end | ||
|
||
def self.add_width_height_ratio(size) | ||
ratio = caculate_width_height_ratio(width: size.width, height: size.height) | ||
size.update(width_by_height: ratio) | ||
end | ||
|
||
def self.caculate_width_height_ratio(width:,height:) | ||
ratio = width.to_f / height.to_f | ||
end | ||
end |
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
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
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
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
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
5 changes: 5 additions & 0 deletions
5
db/migrate/20171011011341_add_raitio_to_cached_flickr_photo_size.rb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddRaitioToCachedFlickrPhotoSize < ActiveRecord::Migration | ||
def change | ||
add_column :cached_flickr_photo_sizes, :width_by_height, :float | ||
end | ||
end |
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