Skip to content

Conversation

@arangn
Copy link

@arangn arangn commented Nov 10, 2018

Video Store API

Congratulations! You're submitting your assignment!
If you didn't get to the functionality the question is asking about, reply with what you would have done if you had completed it.

Comprehension Questions

Question Answer
Explain how you came up with the design of your ERD, based on the seed data. We envisioned how a user will create an application using this API and came up with some possible user stories.
What would be the Big-O time complexity of your /customers & /movies endpoints? What does the time complexity depend on? Explain your reasoning. It would be O(n) because it iterates through every movie to render to json. It depends on the length of the movie database
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. It is O(n^2) because we have a nested loop. The time complexity depends on the time to iterate through the nested loops and find the movie and customer.
Describe a set of positive and negative test cases you implemented for a model. Positive test- the movie available inventory decrements and increments when a movie is checked in/out. Negative test- rental will not be valid with a missing field
Describe a set of positive and negative test cases you implemented for a controller. Positive test- for the rental show, it retrieves a rental if it can find all the parameters. Negative- if it cannot find the parameters it will render an error
How does your API respond when bad data is sent to it? It renders an error and displays the error message.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We created a decrement movie available inventory method, and we put it in the model to maintain single responsibility for our create/checkout controller method.
Do you have any recommendations on how we could improve this project for the next cohort? Not really
Link to Trello https://trello.com/b/YSLWYkSG/video-store
Link to ERD https://files.slack.com/files-pri/TASRJV6S2-FDXDCPNN9/image_from_ios.jpg
Summary

arangn and others added 30 commits November 5, 2018 11:47
setup database, models, controllers
movie model testing, all pass
tests for customer models
fix relations in models
movie controller tests, all passing
customer controller tests passing
require :movie on params
add due date to rentals
@tildeee
Copy link

tildeee commented Nov 20, 2018

Video Store

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene x
Comprehension questions x
General
Business Logic in Models x
All required endpoints return expected JSON data x
Requests respond with appropriate HTTP Status Code x
Errors are reported x
Testing
Passes all Smoke Tests passing all wave 3 tests, failing wave 2 tests on movie
Model Tests - all relations, validations, and custom functions test positive & negative cases x, missing a few model tests
Controller Tests - URI parameters and data in the request body have positive & negative cases x, missing a lot of rental controller tests
Overall

Hello! Good work on this project-- If I adjust one line in your code, then all smoke tests from both waves pass!

I see a lot of missing work around rental controller tests, though.

Ultimately, the code that's written is great-- the finished unit tests and finished controller tests look great. I particularly like the refactoring y'all did to make the model logic more robust.

I want to make sure y'all feel good about these learning goals, so let me know if you have any questions:

  • Build an ERD and set up ActiveRecord models for a given dataset / use-case
  • Expose database contents through a web API
  • Respond reasonably to bad user data in the context of an API
  • Verify the correctness of an API using controller tests

private

def movie_params
params.require(:movie).permit(:title, :overview, :release_date, :inventory)
Copy link

Choose a reason for hiding this comment

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

In Rails when we used forms, params would come back populated with a nested structure that had movie in it. In this API, we won't have that nested structure, so we need to take out the .require('movie') bit. When we do this, then the rest of Wave 2 starts working :)


checked_out = customer.movies_checked_out_count
customer.update(movies_checked_out_count: checked_out - 1)
end
Copy link

Choose a reason for hiding this comment

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

Yes! These are wonderful methods. I love that the logic is in Rental, and it very much delegates movie logic to movie, and customer logic to customer. This is perfect! Keep it up, this is great.

end
it "decrements available_inventory by one" do
rental = Rental.new(check_out_date: "Wed, 29 Apr 2015 07:54:14 -0700", check_in_date: "Wed, 6 May 2015 07:54:14 -0700", due_date: "Wed, 6 May 2015 07:54:14 -0700", customer_id: customers(:one).id, movie_id: movies(:one).id)
binding.pry
Copy link

Choose a reason for hiding this comment

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

Y'all had one last uncommented binding.pry

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.

3 participants