Skip to content

Conversation

@cojenco
Copy link

@cojenco cojenco commented May 29, 2020

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 were able to come up the initial design of the 2 models, and we were able to determine that Rental connected Video and Customer.
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 total number of customers or 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) since we always do a linear search to find the video and customer.
Describe a specific set of positive and negative test cases you implemented for a model. In the check_availability method, we tested positive cases to return true when there are available inventory. On the other hand, we tested negative cases where there is zero inventory.
Describe a specific set of positive and negative test cases you implemented for a controller. To test videos#checkout, we tested positive cases where customer_id and video_id were valid and there were available inventory. For negative cases, we tested invalid customer ids and invalid video ids.
Broadly, describe how an API should respond when it handles a request with invalid/erroneous parameters. We return a bad_request or not_found. We also included a detailed error message.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. Many of our custom methods were one-line code, but considering reusability and best practice (modular), we chose to create them. Also, the checkout method was really lengthy, so it made sense to wrap that functionality into a custom method.

cojenco and others added 30 commits May 26, 2020 14:08
@dHelmgren
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

Comment on lines +51 to +58
video.increase_inventory
customer.decrease_videos_checked_out_count
render json: {
"customer_id": customer.id,
"video_id": video.id,
"videos_checked_out_count": customer.videos_checked_out_count,
"available_inventory": video.available_inventory,
}, status: :ok

Choose a reason for hiding this comment

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

When changing multiple aspects of a database in the same controller action, it's good to make sure that one change doesn't happen without the other. This is a good use for something called "Transactions".

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