forked from corincerami/mars-photo-api
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement photo size parameter #1
Merged
Merged
Conversation
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
Added new cameras
feat: add perseverance rover image
Add new cameras to seeds and upgrade Rails
Permit :rover_id
…sion_3_0_0 Upgrade Ruby to 3.0.0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request addresses multiple issues around the consistency and control of photo sizing (corincerami#117 and corincerami#130).
Going forward, users may pass a
size
parameter that will specify the size of the returned photos. This is achieved by altering the suffix of eachimg_src
in thephotos_controller.rb
andlatest_photos_controller.rb
to correspond with the requestedsize
androver_id
. I stored the logic for resizing inphoto_helper.rb
so it can be shared between both controllers.Original suffixes (what is stored in the database)
.jpg
or.JPG
-BR.JPG
-BR.JPG
_1200.jpg
New suffix outputs
small
-thm.jpg
-THM.JPG
-THM.JPG
_320.jpg
medium
-br.jpg
-BR.JPG
-BR.JPG
_800.jpg
large
ornil
.JPG
.JPG
.JPG
_1200.jpg
full
.png
Note: Some of these suffixes are case sensitive
Other changes
params
androver
fromphotos_controller.rb
andlatest_photos_controller.rb
toPhoto.search
method inmodels/photo.rb
latest_photos_controller.rb
(Non-breaking syntax error in latest_photos_controller.rb corincerami/mars-photo-api#145)latest_photos_controller.rb
photos_controller.rb
andlatest_photos_controller.rb
withsize
parameterimg_src
is sequenced inspec/factories.rb
, so it does not conflict with tests involvingsize
parameterPotentially problems for users
size
parameter, photos from Opportunity and Spirit rovers will now be served in theirlarge
format; whereas they used to be served asmedium
.Note to devs before merge
I have not tested these changes extensively with Opportunity and Spirit photos, because their scrapers are deprecated. Please test on a full development version of the API with Opportunity and Spirit photos before merging.