Skip to content

Conversation

@veralizeth
Copy link

Assignment Submission: Video Store API

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.

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.

Reflection

Prompt Response
Explain how you came up with the initial design of your ERD, based on the seed data and reading through the API endpoints We first read through the requirements and sketched out which databases we thought we needed. Once we had a high level design down, we looked at the seed data and API endpoints to see what we should name our columns.
What would be the Big-O time complexity of your /customers & /videos endpoints? What does the time complexity depend on? Explain your reasoning. For the customer endpoint, we thought that the time complexity would be O(n) since it needs to present each of the customers; therefore, an increase of one customer should increment the time it needs to load the data by one. We also think that the video endpoint should also be O(n), for the same reason.
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. We thought that the check in endpoint is O(n) because it needs to look through video and customer databases to find the current customer and video related to the rental. However, the search isn’t done in a nested loop, so therefore the search is still O(n).
Describe a specific set of positive and negative test cases you implemented for a model. We tested to make sure that the number of available videos decreases when a rental is made, and that it doesn’t change if the rental does not go through.
Describe a specific set of positive and negative test cases you implemented for a controller. We tested to make sure that a check-out can be performed if the video and customer exist, but not if they do not.
Broadly, describe how an API should respond when it handles a request with invalid/erroneous parameters. An API should return a 4XX or 5XX response when it handles a request with invalid/erroneous parameters.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We put incrementing/decrementing the available videos within the model method. We did this because we thought it would be cleaner to modify the data for a different database within it’s model, rather in the controller of where the function was getting called.

@jmaddox19
Copy link

Video Store API

Major Learning Goals/Code Review

Criteria yes/no, and optionally any details/lines of code to reference
Practices git with at least 10 small commits and meaningful commit messages ✔️ So many commits with good messages!
Understands the importance of how APIs handle invalid/erroneous data in their reflection questions 5XX codes are actually only intended to be returned when the user has provided perfectly valid input and something unpredictable went wrong with the service itself. It would be more accurate to say that the api should respond with a 3XX or 4XX response, for redirect or bad request.
Practices Rails best practices and well-designed separation, and encapsulates business logic around check-out and check-in in models ✔️
Uses controller tests to ensure quality code for every route, and checks for response status and content, with positive cases and negative cases ✔️ Great controller testing!!
Uses controller tests to ensure correctness for check out and check in requirement, and that checked out counts and inventories appropriately change ✔️ Yes, though I am confused about the inventory count check in the checkin test. See inline comments for more details.

Functional Requirements

Functional Requirement yes/no
All provided smoke tests for Wave 1 pass ✔️
All provided smoke tests for Wave 2 pass ✔️

Overall Feedback

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 3+ in Code Review && 2 in Functional Requirements ✔️
Yellow (Approaches Standards) 2+ in Code Review && 1+ in Functional Requirements, or the instructor judges that this project needs special attention
Red (Not at Standard) 0-1 in Code Review or 0 in Functional Reqs, or assignment is breaking/doesn’t run with less than 5 minutes of debugging, or the instructor judges that this project needs special attention

Additional Feedback

Great work y'all! The API is fully functional and the code is so clean!

The only small area for growth I see is around getting more familiar/confident with HTTP status codes. The comprehension questions mentioned returning 5XX codes when the user gives bad input, which is inaccurate.
The code itself actually gives 4XX response codes in places where it'd be appropriate to give 5XX response codes. That said, we haven't gone over 5XX status codes very thoroughly.

Code Style Bonus Awards

Was the code particularly impressive in code style for any of these reasons (or more...?)

Quality Yes?
Perfect Indentation
Elegant/Clever
Descriptive/Readable
Concise
Logical/Organized

Comment on lines +130 to +131
expect(video.available_inventory).must_equal inventory_count
expect(customer.videos_checked_out_count).must_equal video_count

Choose a reason for hiding this comment

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

I think I might be missing something but I'm confused why these numbers aren't meant to change when the user checks in a rental.

Choose a reason for hiding this comment

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

From looking at the source code in the controller, I'm surprised and confused why this passes. I must be reading something wrong.

render json: {
ok: false,
errors: rental.errors.messages,
}, status: :bad_request

Choose a reason for hiding this comment

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

There's actually no chance for the user input to be invalid in this case because we've already validated that we can find the customer and video specified by the user.
If we are going to add an else block here, we should actually return an :internal_server_error because the failure to save would be due to something wrong with the database.

Choose a reason for hiding this comment

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

Please reach out to me if this comment is unclear! :)

render json: {
ok: false,
errors: rental.errors.messages,
}, status: :bad_request

Choose a reason for hiding this comment

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

Similar to with checkout, this would be more accurate as :internal_server_error

else
render json: {
errors: @video.errors.messages,
}, status: :bad_request

Choose a reason for hiding this comment

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

Here it is appropriate to respond with a :bad_request status because a failure to save is most likely due to failed validations.
Technically, it's also possible that the save fails due to a connection failure, even if the validations pass, but that's more depth of error-handling than we've gotten into in our curriculum.

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