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

Ana Lisa Sutherland: API Muncher -Octos C9 #34

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

Conversation

The-Beez-Kneez
Copy link

@The-Beez-Kneez The-Beez-Kneez commented May 7, 2018

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 explored the documentation available for Edemam Api, and looked at which elements I wanted to utilize to get the recipe information I needed. Then I used Postman to check what information was given to double check that I was getting the info I needed.
Describe your API Wrapper. How did you decide on the methods you created? I only have two methods for my API Wrappers and 1 helper method. I have search-based method that lets you return 40 results for an entered query and a show method that displays information for a selected recipe.
Describe an edge case or failure case test you wrote for your API Wrapper. I wrote a case where the entered query did not exist, I do not believe that the test is working, however.
Explain how VCR aids in testing an API. It allows the writer to record api info instances and reuse them for testing purposes. This allows you to cut back on the number of api requests you need to send.
What is the Heroku URL of your deployed application? https://munch-munch.herokuapp.com/
Provide a link to the Trello board you used https://trello.com/b/PN9faRdK

Just realized I forgot to have the recipe source url reopen in a new tab, got too bogged down trying to get tests to work....

@droberts-sea
Copy link

API Muncher

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene mostly - you've committed your log and tmp directories, which have added thousands of auto-generated Rails files to your diff
Comprehension questions yes
General
Rails fundamentals (RESTful routing, use of named paths) no - see inline
Semantic HTML some - lots of <div>s that could be more semantic
Errors are reported to the user some - mangling the show URL results in an exception, not a polite error message
API Wrapper to handle the API requests yes
Controller testing no
Lib testing no - Some controller-style testing is mixed in here, and none of it actually runs for me. Seems like there's a big disconnect from what you're supposed to be doing here.
Search Functionality yes
List Functionality yes
Show individual item functionality (link to original recipe opens in new tab) yes - don't worry about the new tab
Styling
Responsive layout no - layout does not adjust for larger screens
List View shows 10 items at a time/pagination yes
The app is styled to create an attractive user interface some
API Features
The App attributes Edaman yes
The VCR casettes do not contain the API key yes
External Resources
Link to Trello Board yes
Link to deployed app on Heroku yes - crashed as soon as I tried to search, did you remember to add your API keys on Heroku?
Overall

This submission is concerning to me. You were able to get the core API functionality working, which is a good start. However there are many important pieces that are missing or broken, including error handling, testing, routing, styling, and deployment. Remembering how to write "regular" Ruby code is part of the challenge of this assignment, but it seems like you're still really struggling with Rails and Ruby fundamentals.

Many of the problems I'm seeing are things that will hamper the rest of your development process. For example, having a good story around error handling makes everything else easier, because when something goes wrong you get a clear reason why instead of having to hunt for it.

When you meet with Charles this week, it would be worthwhile to go over some of these pieces, particularly error handling and testing. Aside from being important on their own, having these locked in a little better will help when we switch to JavaScript next week too.

I know you've been putting in a ton of effort recently, and I want to acknowledge that. I do see improvements happening and progress being made. Keep up your focus and dedication, and things will start falling into place.

<h4><%= recipe.label %></h4>
</li>
<% end %>
</div>

Choose a reason for hiding this comment

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

This </div> should be inside the loop.

<div class= "recipe_info">
<li class= "recipe_img">
<%= link_to image_tag(recipe.image, alt: "recipe-pic", class: "recipe-pic"), recipe_path(uri: recipe.uri) %>
</li>

Choose a reason for hiding this comment

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

You should invert the <li>s and <div>s here, have the children of the <ul> be one <li> per recipe, and have two <div>s within that.

url = BASE_URL + "/search?r=#{encoded_uri}&app_id=#{API_ID}&app_key=#{TOKEN}"
response = HTTParty.get(url)

return Recipe.format_api(response[0])

Choose a reason for hiding this comment

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

You don't have any error handling here. What if the user types in a recipe that doesn't exist?

def initialize(label, options = {})
if label.nil? || label.empty?
raise ArgumentError.new("No name has been provided for this recipe")
end

Choose a reason for hiding this comment

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

Since you need the uri to make the links, you should probably include a check for that here.

recipes = EdemamApiWrapper.search_recipes(query)

get recipes_path, params: {query: "pepper"}
must_respond_with :success

Choose a reason for hiding this comment

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

You both make a request and call the API wrapper directly in this test. You should split these into separate controller and lib tests.

recipes = EdemamApiWrapper.search_recipes("pepper")
recipe = recipes.first

get recipe_path(recipe.id)

Choose a reason for hiding this comment

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

On line 37, you're using a named path, but these aren't defined in your routefile, which is why this fails.

config/routes.rb Outdated

get 'search', action: :index, controller: 'recipes'
get 'index', to: 'recipes#index'
get '/recipe', to: 'recipes#show'

Choose a reason for hiding this comment

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

These routes are not RESTful! That makes the pattern harder to remember, making it more likely that you'll write a bug. You also don't have path names, which means you have to type out the URL as a string everywhere. Instead you should use resources :recipes, only: [:index, :show].

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.

2 participants