Skip to content

Space - Diana & Lee#21

Open
theomoondev wants to merge 76 commits intoAda-C13:masterfrom
theomoondev:master
Open

Space - Diana & Lee#21
theomoondev wants to merge 76 commits intoAda-C13:masterfrom
theomoondev:master

Conversation

@theomoondev
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 As we were reading through the expected response values from each endpoint, we thought about how they would translate into attributes and relationships between the models. When we saw that there was a /rentals endpoint, we deduced that this could be a bridge entity between the Customer and Video entities, and that there would be a many-to-many relationship between Customer and Video through Rentals. We checked our assumptions about entity attributes against the seed data.
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), where n is the number of records retrieved. Our theory is that the order method retrieves the records into an array and sorts in one iteration.
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), where n is the number of Rental records. We iterate through the Rental collection once to find the one that has the given customer_id and video_id. Our theory is that increment_counter() and decrement_counter() don't add to time complexity.
Describe a specific set of positive and negative test cases you implemented for a model. We checked whether the program would respond as expected if all the required fields were either present, nil, or an invalid datatype.
Describe a specific set of positive and negative test cases you implemented for a controller. We checked whether our endpoints would respond with a :success if given the required/proper params, and whether they would respond with :bad_request or :not_found when given improper params.
Broadly, describe how an API should respond when it handles a request with invalid/erroneous parameters. It should return an errors hash with detailed error messages and a status code in the 400 range.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. The self.checkout method in the Rental model increments the given customer's videos_checked_out_count and decrements the given video's available_inventory, and updates the customer's and video's updated_at values. We chose to wrap that functionality into a method because it increases readability in the controller method. If we were required to write tests for model methods too, we could also test for more granular cases.

dnguye2 and others added 30 commits May 26, 2020 14:51
Customers Index Controller Action & Tests
Videos Index Controller Action and Tests
theomoondev and others added 28 commits May 28, 2020 17:12
…ncrements available_inventory, and sets the due_date to nil
…ry, and update due_date logic to video model method
…ion-tests

Customer and Rental Validations Tests
@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 built a fully functional API!

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

end

Rental.check_out(rental.customer_id, rental.video_id)
# For some reason, we needed to reload the customer and video in order to get the updated counts

Choose a reason for hiding this comment

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

This is what I'd expect here. :)
You updated the values in the database but need to reload to see the new values reflected in the scope of the variables in this method.

return
else
render json: {
errors: rental.errors.messages

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 that the request could be bad at this point because the customer_id and video_id have already been verified on line 9. Hence you don't have a unit test that verifies this case.

customer.reload
video.reload

rental.due_date = Time.now + 7.days

Choose a reason for hiding this comment

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

Minor: This could have been nice to add to the check_out method as well

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