Skip to content

Conversation

@kguadron
Copy link

@kguadron kguadron commented May 15, 2019

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 looked at the seed data to inform the attributes and relationships we need to include in our models.
What would be the Big-O time complexity of your /customers & /movies endpoints? What does the time complexity depend on? Explain your reasoning. O(n) where n is the number of movies/customers because it went through the whole data base and either lists all or searches for a specific movie.
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. O(1) because we use the parameters to query the database for the specific record.
Describe a set of positive and negative test cases you implemented for a model. For our models we tested if the model had all required attributes and that it rejected anytime all the required attributes were missing.
Describe a set of positive and negative test cases you implemented for a controller. We tested that we were able to create a new record given valid data and that errors were raised when the creation failed.
How does your API respond when bad data is sent to it? It sends errors and a bad request status.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We wrote a movie model filter that sets the available inventory equal to inventory before a movie instance is created. We chose to do this because we wanted this attribute assignment to happen every time we initiated a movie.
Do you have any recommendations on how we could improve this project for the next cohort? Fix the smoke tests
Link to Trello https://trello.com/b/dKLBYSwG/video-store
Link to ERD https://drive.google.com/file/d/1ZbIfdajQEKbNMvHHB86L1qpoKMndHRA5/view
Summary Positive experience building an API!

kguadron and others added 30 commits May 14, 2019 11:25
Wrote index customer controller action and tests
passed tests for create movie action
@dHelmgren
Copy link

Video Store

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene good
Comprehension questions good
General
Business Logic in Models Lots, see comment!
All required endpoints return expected JSON data good
Requests respond with appropriate HTTP Status Code yes
Errors are reported yes
Testing
Passes all Smoke Tests yes
Model Tests - all relations, validations, and custom functions test positive & negative cases yes
Controller Tests - URI parameters and data in the request body have positive & negative cases yes
Overall good work overall! Keep an eye out for any time you are calculating or saving a value inside a controller. It's probably business logic!

customer = Customer.find_by(id: rental.customer_id)
customer.rental_ids << rental.id
checkouts = customer.movies_checked_out_count
checkouts += 1

Choose a reason for hiding this comment

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

You have a bunch of business logic here! Would it be possible to encapsulate this in a model method? Something like

rental.check_out(customer_id, movie_id)

might be a good interface. That would make this logic easier to test as well.

def show
movie = Movie.find_by(id: params[:id])
if movie
render json: movie.as_json(only: [:id, :title, :release_date, :overview, :available_inventory, :inventory]), status: :ok

Choose a reason for hiding this comment

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

Small style note: not all text editors wrap lines for you. This line is so long that on GitHub I have to scroll horizontally to see all the pieces. You can make this easier to read by putting a newline after any given comma in a statement.

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