Skip to content
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

Queues - Kayla Kubicke - API-Muncher #60

Open
wants to merge 57 commits into
base: master
Choose a base branch
from
Open

Queues - Kayla Kubicke - API-Muncher #60

wants to merge 57 commits into from

Conversation

ghost
Copy link

@ghost ghost commented May 9, 2017

API Muncher

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
How did you go about exploring the Edamam API, how did you try querying the API? I used Postman and the browser to explore and query the API.
Describe your API Wrapper. How did you decide on the methods you created? I created methods based on what I needed. For the search page I built a method that accepts the search term and a page number. This information helps create a url, sends a request to that url, and manipulates the response to produce an array of objects that can be displayed on the show page. For the recipe show page, I made a method that accepts a uri and returns a hash containing the information for the show page.
Describe an edge case or failure case test you wrote for your API Wrapper. In the case that a search response does not return any results, an empty array is returned. (The controller then redirects the user.)
Explain how VCR aids in testing an API. The VCR creates JSON fixtures. These fixtures can be used to run your tests without the internet and avoids repeatedly hitting an API for the same information over and over again.
What is the Heroku URL of your deployed application? https://beyond-ramen.herokuapp.com
Do you have any recommendations on how we could improve this project for the next cohort? N/A

I figured out a way to create page link navigation (i.e. Page 1, Page 2, etc.) without any empty pages. The response['count'] the API returns is always incorrect, it returns many blank recipes so it is an unreliable number to create links with. But, if you send a second request with the response['count'] as the last requested index, you receive a value in the next response called 'to' which returns the actual number of valid recipes. If you send both responses in tandem you can create page navigation without any empty page numbers. It's very slow but it does solve the problem of empty page links. This solution is on my 'pagination' branch.

Kayla and others added 30 commits May 2, 2017 11:59
Updated recipe test to utilize let to make test objects.
Changed recipe attributes to conform to project.
Cleaned up redundant code in test.
Added test to evaluate unsuccessful search term result.
Added logic and message for redirect if unsuccessful search term is entered.
…t of site.

Show page displays name, list of ingredients, and link to original page.
Library and controller pass along parameters and create variables correctly for show page.
Updated concept of site and added easter egg.
Kayla and others added 25 commits May 6, 2017 11:38
Removed incorrect attribute tests.
Added edge cases for both methods.
A valid uri returns a recipe show page and an invalid one redirects.
Empty search term redirects to root page.
…d root_path redirects in controller tests.
Decided to go more towards a sarcastic 70's hair ad vibe.
@droberts-sea
Copy link

API Muncher

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene yes
Comprehension questions yes
General
Rails fundamentals (RESTful routing, use of named paths) yes
Semantic HTML needs improvement - I see lots of <div>s, many of which could probably be something more semantic like <section> or <article>. Also, at a high level your page seems like it could be organized into <header> and <main> sections.
Errors are reported to the user yes - good work!
API Wrapper to handle the API requests yes - see inline comments
Controller testing yes
Styling
Foundation Styling for responsive layout yes
Search View yes
List View yes
Show View which opens in a new tab yes (not in a new tab, but looks good)
API Features
The App attributes Edaman no - This is one of the conditions for using their API! You should have some their logo in your site's footer, as well as something like "Powered by Edamam".
The VCR casettes do not contain the API key yes
Overall

Good work overall! Make sure to check out the inline comments - mostly small style things that don't fit up here.

</head>
<div class='row'>
<div class="style1" align='center' height='35'>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this stuff should be nested inside the <body> tag.

@@ -0,0 +1,16 @@
<div class='row nav'>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that you've moved this code into a partial.

</div> <!-- These logic is here to keep the spacing in the page correct. -->
<% else %>
<div class='small-4 column' id='left-nav'>
<%= link_to "Previous Recipes", recipes_path(:utf8 => params[:utf8], :search => params[:search], :page => (params[:page].to_i - 1), :commit => params[:commit]) %>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this code is certainly functional, it's also a little clunky. Is there any way you could use a helper method here to clean it up?

lib/recipe.rb Outdated
recipe_components[:ingredients] = response[0]['ingredientLines']
recipe_components[:diet] = response[0]['dietLabels']

return recipe_components

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's interesting to me that above you return Recipe objects, but here you return a hash. Seems to me you could add a little bit of functionality to Recipe and be able to reuse it nicely.

lib/recipe.rb Outdated
end

def self.show_recipe(uri)
url = "https://api.edamam.com/search?app_key=#{ENV['APP_KEY']}&app_id=#{ENV['APP_ID']}&r=http://www.edamam.com/ontologies/edamam.owl%23#{uri[1..-1]}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both the base URL and the ontologies URL would be good candidates for class constants here.

Kayla added 2 commits May 10, 2017 12:35
Worked with Charles to DRY up Recipe Model and made method that
exclusively creates Recipe objects.
Adjusted tests to pass after the above changes, added tests for new
method.
Addressed most html comments, except navigation helper method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant