Skip to content

Conversation

@bonara
Copy link

@bonara bonara 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 checked the seed data for the attribute names and data types. By looking at the seed data, we noticed that movies and customers didn't have a direct relationship as there were no foreign keys. Thus, we decided to create a rental table that connected both customer and movie data.
What would be the Big-O time complexity of your /customers & /movies endpoints? What does the time complexity depend on? Explain your reasoning. Big-O time complexity for /customers & /movies endpoints will be O(n), where n is the length of the customers or movies. We think that .all function in index method is looping through all the customers or movies records to return the data.
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. For POST /rentals/check-in endpoint, we think that time complexity is O(n), where n is the number of rentals. We are using where function and know that it returns an array of records that match the search criteria. Since where loops through all the rentals, we think the time complexity is O(n).
Describe a set of positive and negative test cases you implemented for a model. For movie model available_inventory method, we have tested if the available_inventory is decreased when movie is checked out. And for the edge case, we set the inventory to 0, to check if available inventory also returns 0.
Describe a set of positive and negative test cases you implemented for a controller. For a checkin controller test, we tested if the checked out rental movie can be checked in. For a negative test case, we checked that rental cannot be checked in there is no checked out rental.
How does your API respond when bad data is sent to it? We render JSON error messages if bad data is sent to our endpoints.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We created movies_checked_out_count method for customer model to count the customer's checked out rentals. We decided to wrap this functionality into a method since it is a business logic.
Do you have any recommendations on how we could improve this project for the next cohort? Schedule this project after a solo assignment.
Link to Trello https://trello.com/b/0a5uYN37/videostoreapi
Link to ERD https://www.lucidchart.com/documents/edit/ab137789-8af8-415d-a33d-2bdf3a5dba74/0?shared=true&
Summary We enjoyed working together. Yay for cross class pairing!

@droberts-sea
Copy link

Video Store

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene yes
Comprehension questions yes
General
Business Logic in Models some - see inline
All required endpoints return expected JSON data yes
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 - good work!
Overall Great job overall. I'm particularly happy with your test coverage. I do see some work for growth around identifying and isolating model methods. This won't be quite as straightforward to practice in JavaScript since we'll be so focused on display logic, but there will definitely be opportunities to isolate business logic. Other than that I like what I see - keep up the hard work.

if movie
render json: movie.as_json(except: [:id,:created_at, :updated_at], :methods => [:available_inventory]), status: :ok
else
render json: { "errors": ["Movie was not found"]}, status: :not_found

Choose a reason for hiding this comment

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

I would probably break line 10 up across multiple lines.

movie = Movie.find_by(id: rental_params[:movie_id])
if movie
if movie.available_inventory > 0
rental = Rental.new(rental_params.merge(checkout_date: Date.today, due_date: Date.today + 7))

Choose a reason for hiding this comment

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

Would it be possible to encapsulate this business logic in a model method? Something like Rental.check_out(customer_id, movie_id) might be a good interface.


def movies_checked_out_count
self.rentals.where(checkin_date: nil).count
end

Choose a reason for hiding this comment

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

I love that you made Customer#movies_checked_out_count and Movie#available_inventory methods instead of storing them in the database. That way there's no way to forget to update these values.

it "renders status bad request" do
get movie_path(-1)
must_respond_with :not_found
end

Choose a reason for hiding this comment

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

Since you send back specific JSON in the error case, it would be good to check that here as well.

body = JSON.parse(response.body)

expect(body).must_be_kind_of Hash
expect(body).must_include "errors"

Choose a reason for hiding this comment

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

I like that you verify error JSON here.

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