Skip to content

Conversation

@jessicacaley
Copy link

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 mostly used the spec readme to determine what our ERD design was, and then had to fix a couple of variable names once we referenced the seed data. Logically, it made sense for Rental to be a join table-esque model that held foreign keys for Movie and Customer.
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 and space complexity of each is linear, or O(n), where n is the number of customers or movies in the database. The space complexity is based on the creation of the array "movies" or "customers" because those variables take up more space depending on the length of the array being created. We're assuming the time complexity of rendering the JSON increases linearly with the length of that array, in turn.
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. Time complexity of the check-in endpoint is O(log(n)), or logarithmic. It needs to find the movie based on the index, which performs a binary search on the database. Space complexity would be constant because we're only ever storing one instance of Movie.
Describe a set of positive and negative test cases you implemented for a model. On the Movie model, we tested validations for if all required fields were present, a positive test case, and if it was missing, say, a title (a negative test case with errors).
Describe a set of positive and negative test cases you implemented for a controller. For the Rentals Controller, we tested that check-in would update a rental with the current date for checkin_date if given a valid rental id (positive case) and that it would respond with not found if given an invalid id (negative case).
How does your API respond when bad data is sent to it? We send back bad request with errors in the body of the JSON response.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We originally were going to have a custom model method for rental that would set the checkout date to the current date and the due date to 7 days after the current date, but we ended up moving that functionality to the rentals controller because it seemed to make more sense.
Do you have any recommendations on how we could improve this project for the next cohort? "Cross class is cool!" -Hana Clements, 2019
Link to Trello https://trello.com/b/m341qGCb/videostore
Link to ERD See "Done" column on Trello (link above)
Summary "APIs are cool!" -Hana Clements, 2019

hanalways and others added 30 commits May 14, 2019 13:36
@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 NOPE
All required endpoints return expected JSON data Check, except available_inventory
Requests respond with appropriate HTTP Status Code Check
Errors are reported Check
Testing
Passes all Smoke Tests NOPE because you defined routes which were against the spec assigned.
Model Tests - all relations, validations, and custom functions test positive & negative cases Basic model tests, you didn't add business logic so nothing to test there.
Controller Tests - URI parameters and data in the request body have positive & negative cases You are probably too granular in testing for all the fields that could cause create to fail in movies_controller_test.rb.
Overall Your check-out and check-in routes are not aligned with the requirements of the project. The smoke tests should have made that clear. You also have no business logic in your models, you could push down the check-in and check-out processes and calculating number of available movies into methods. You hit most of the learning goals, but this could have been done more throughly.

resources :movies, only: [:index, :show, :create]

post "rentals/check_out", to: "rentals#check_out", as: "check_out"
post "rentals/:id/check_in", to: "rentals#check_in", as: "check_in"

Choose a reason for hiding this comment

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

You shouldn't need the route parameter for this action as per the assignment. Also the routes are different from the spec.

end

def zomg
render json: {works: "it works!"}

Choose a reason for hiding this comment

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

No status code?

t.string "title"
t.string "overview"
t.date "release_date"
t.integer "inventory"

Choose a reason for hiding this comment

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

You either need to have an available inventory field, or better yet a method to calculate the available inventory.

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