Skip to content

Conversation

@ktvoort123
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 looked at the names of the entities that were needed and the column names which dictated the attributes for our objects.
What would be the Big-O time complexity of your /customers & /videos endpoints? What does the time complexity depend on? Explain your reasoning. The time complexities for the /customers & /videos endpoints are O(n), where n is the length of the collection.
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. The time complexity for our POST /rentals/check-in endpoint is O(n), where n is the length of the rentals collection.
Describe a specific set of positive and negative test cases you implemented for a model. For video, a positive case was that we could successfully create a video if all required fields were present. A negative case was if available inventory wasn't provided or the title wasn't provided.
Describe a specific set of positive and negative test cases you implemented for a controller. A positive case is if a user and customer id were provided for a rental. A negative case is if a user id or customer id was not provided or was invalid.
Broadly, describe how an API should respond when it handles a request with invalid/erroneous parameters. An API should respond with a response code specifying the error, and when possible, should return the error message(s) in the response body.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We chose not to create any model methods, but if we were to do this project again, we would move check-in and check-out to the rental model, rather than have all of the logic within the controller.

@beccaelenzil
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 See in-line comments.
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 ✔️

Code Style Bonus Awards

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

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

Copy link

@beccaelenzil beccaelenzil left a comment

Choose a reason for hiding this comment

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

Good work on this project! Your code is well written and well tested. The one main piece to note is that the logic for checking in and checking out a video should be in the model. There are ways to do this in the customer/video models, or the rental model. Please let me know if you have any questions. Keep up the hard work!

}, status: :not_found
return
elsif rental.save
video.available_inventory -= 1

Choose a reason for hiding this comment

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

Changing the counts is business logic that should go in the model. One way to think about whether it's business logic or not is to consider if you are manipulating the data. If you are, stick it in the model!

errors: ["Not Found"],
},status: :not_found
elsif rental
rental.customer.videos_checked_out_count -= 1

Choose a reason for hiding this comment

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

Similar to above, this business logic should go in the model.

video = Video.find_by(id: rental[:video_id])
customer = Customer.find_by(id: rental[:customer_id])

expect(video.available_inventory).must_equal inventory + 1

Choose a reason for hiding this comment

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

Consider using must_differ as above.

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