Skip to content

Conversation

@laneia
Copy link

@laneia laneia commented May 16, 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. Based on what data was provided it became clear what columns needed to be added for each class and how they related to one another.
What would be the Big-O time complexity of your /customers & /movies endpoints? What does the time complexity depend on? Explain your reasoning. The time complexity is O(n). Time complexity depends on the data structure and the amount of data in it. In this case, since /customers and /movies indexes all of the data, the time complexity is a direct function of how much data there is.
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. The rentals/check-in method time complexity is O(log(n)). The time complexity depends on how long it takes to use find_by to locate the data corresponding to the customer_id and movie_id, which is essentially a binary search.
Describe a set of positive and negative test cases you implemented for a model. In the customer model we have a positive validation test to ensure it requires the name field for a customer. A negative test case is making sure the customer is invalid without providing the name field.
Describe a set of positive and negative test cases you implemented for a controller. In the customers controller we have a positive test case for returning all of the customers. There is a negative test case for returning an empty array if there are no customers.
How does your API respond when bad data is sent to it? It responds with an error hash with a message related to the error cause.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We added an available? method to the rental model that takes in a movie_id as input. This made sense to add to the rental model because it checks to ensure a movie has enough available inventory to be checked out before a new rental can be created.
Do you have any recommendations on how we could improve this project for the next cohort? Not really.
Link to Trello N/A
Link to ERD https://i.imgur.com/sdTcFOV.jpg

laneia and others added 28 commits May 15, 2019 13:56
@CheezItMan
Copy link

Video Store

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene Good number of commits and good commit messages
Comprehension questions Check
General
Business Logic in Models Good business logic methods!
All required endpoints return expected JSON data Check
Requests respond with appropriate HTTP Status Code Check
Errors are reported Check
Testing
Passes all Smoke Tests Once routes are adjusted, yes
Model Tests - all relations, validations, and custom functions test positive & negative cases Check
Controller Tests - URI parameters and data in the request body have positive & negative cases Some missing test cases here. See my inline comments.
Overall Your routes were a little off what was expected. Once fixed things worked well. You also had some areas to improve in controller testing. You did hit all the requirements for the project. Well done.

end

def checkin
rental = Rental.find_by(movie_id: rental_params[:movie_id], customer_id: rental_params[:customer_id], status: "Checked Out")

Choose a reason for hiding this comment

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

  1. This line is too long, instead break it up over several lines.

validates :title, :overview, :release_date, presence: true
validates :inventory, :available_inventory, presence: true, numericality: {only_integer: true, greater_than_or_equal_to: 0}

def available_inventory

Choose a reason for hiding this comment

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

Good business logic method!


validates :customer_id, :movie_id, :due_date, :checkout, :status, presence: true

def available?(movie_id)

Choose a reason for hiding this comment

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

👍

@@ -0,0 +1,28 @@
require "test_helper"

describe Customer do

Choose a reason for hiding this comment

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

No tests for relationships, minor

end
end

describe "routes" do

Choose a reason for hiding this comment

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

routes?

get movie_path(movies(:one).id)
body = JSON.parse(response.body)

expect(body.keys.sort).must_equal movie_fields

Choose a reason for hiding this comment

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

👍

}
}

it "can create a new rental provided valid data" do

Choose a reason for hiding this comment

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

What about if there are no available movies?

end
end

describe "checkin" do

Choose a reason for hiding this comment

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

What about trying to check in a movie which isn't checked out?

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