Skip to content

Conversation

@stephaniejmars
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 Looked at seed data, endpoints, and goals of program and mapped out with drawing what models/controllers we needed, what they contained, and relationships.
What would be the Big-O time complexity of your /customers & /videos endpoints? What does the time complexity depend on? Explain your reasoning. O(n) n being number of customers/videos
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(n + m) n being how many customers, m being how many videos, because find_by is searching database.
Describe a specific set of positive and negative test cases you implemented for a model. In Rental model we test a rental can be created with valid cust and vid data, and also tested without valid data.
Describe a specific set of positive and negative test cases you implemented for a controller. With check_in we tested a normal check_in, and for a negative case we checked in a video twice and checked that the second time was not successful and did not change inventory counts.
Broadly, describe how an API should respond when it handles a request with invalid/erroneous parameters. The API should send back a JSON with error information and also a status code such as not_found or bad_request.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. Whoops we did everything in the controller, but now we know we should have made model methods for checked out count and available inventory updates.

leahwho and others added 29 commits May 26, 2020 14:12
…ideo, increasing video checked out count in customer
@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 ✔️
Understands the importance of how APIs handle invalid/erroneous data in their reflection questions ✔️
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 ✔️
Uses controller tests to ensure correctness for check out and check in requirement, and that checked out counts and inventories appropriately change ✔️

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! Such thorough testing!

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 +51 to +59
if customer.nil? || video.nil?
render json: { errors: ['Not Found']}, status: :not_found
return
end

if rental.nil?
render json: { errors: ['Rental not valid'] }, status: :bad_request
return
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 separated these out into two separate cases to give a more clear error message to the user!

Comment on lines +63 to +64
customer[:videos_checked_out_count] -= 1
customer.save

Choose a reason for hiding this comment

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

It'd be slightly cleaner if these two lines were setup as a method in the customer model so that it could be only one line here.

Comment on lines +66 to +67
video[:available_inventory] += 1
video.save

Choose a reason for hiding this comment

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

Same here as above, but in the video model.

Comment on lines +39 to +42
else
render json: { errors: rental.errors.full_messages }, status: :bad_request
return
end

Choose a reason for hiding this comment

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

There doesn't seem to be to be a way for the user's request to be bad at this point because the customer_id and the video_id have already both been verified.
Because of that, it could still be appropriate to have an else clause here but the only way it'd get executed is if the connection to the database failed. In that case, the more appropriate status would be an :internal_server_error.

Choose a reason for hiding this comment

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

Please let me know if this comment is unclear!

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