Skip to content

Conversation

@easternwashingaden
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 From the seed data, we knew that we would need two classes, and we decided to have add another Rental class after reading the functional specs. We decided to have the Rental class/model as a indirection relationship between Customer and Video.
What would be the Big-O time complexity of your /customers & /videos endpoints? What does the time complexity depend on? Explain your reasoning. For customers, the time complexity is O(n), and it depends on the number of customers. For videos, the time complexity is O(n), and it depends on the number of 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. For POST /rentals/check-in, the time complexity is O(n), and it depends on number of rentals.
Describe a specific set of positive and negative test cases you implemented for a model. We tested only for the Video model.The positive test case is when there are all valid parameters, then we can successfully create the instance. In contrast, for the negative test cases, where there is an invalid field, then we can't create an instance for the Video.
Describe a specific set of positive and negative test cases you implemented for a controller. Positive test case: successfully check out if the customer_id and video_id are valid and video.available_inventory is not 0. Negative test: when the customer try to rent a video that has 0 available_inventory.
Broadly, describe how an API should respond when it handles a request with invalid/erroneous parameters. It would render not_found or bad_request depends on what parameters were.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We implemented it without any customer model methods.

easternwashingaden and others added 30 commits May 26, 2020 14:14
@jmaddox19
Copy link

jmaddox19 commented Jun 10, 2020

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! You 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

Comment on lines +27 to +32
if rental.save

customer.videos_checked_out_count += 1
customer.save
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.

This logic would be appropriate to put in models.
As a general rule, any time I see more than one line of code that isn't directly related to the user-control-flow of the application, I ask myself: "could I pull this code out into a model?"

else
render json: {
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 that the request could be bad at this point because the customer_id and video_id have already been verified on lines 4 & 5.

Choose a reason for hiding this comment

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

Hence you don't have a unit test that verifies this case.

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