Skip to content

Conversation

@katemyer
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 Based on the project requirements, seed data was provided for customers and videos. These were clear indications that classes were needed for these constructs. We created another controller called Rentals for organizational purposes and we felt that it made sense to contain our custom methods here.
What would be the Big-O time complexity of your /customers & /videos endpoints? What does the time complexity depend on? Explain your reasoning. For Customer and Videos, it is O(n) because both endpoints depend on the number of records.
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. While there are parts of the check-in method that are O(1) because we are doing checks(if statements), the highest time complexity is O(n) when we are querying the DB looking for available rentals.
Describe a specific set of positive and negative test cases you implemented for a model. Validations were tested, positive case is when a video has a title and negative case is when the video does not contain a title which renders it invalid.
Describe a specific set of positive and negative test cases you implemented for a controller. Positive case: For videos- in the show action, it will return a hash with proper fields. Negative case: in the show action, if an invalid paramaters are provided, then it will return a a 404 request with JSON.
Broadly, describe how an API should respond when it handles a request with invalid/erroneous parameters. It should display the correct status code and a message.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We had two custom methods, one of which is a check_out method that lives in the rental controller. This method is used to decrease the amount of inventory available and decirease the number of videos checked out any time a customer rents a video. This method was created in this specific controller because it made sense, but since we set up relations between rental and customers and rentals and videos, they too had access to these custom methods.

@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 The answer to the reflection question is too vague. What is are the potentially appropriate status codes when invalid parameters are given?
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 thorough testing! And 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

Comment on lines +61 to +82
customer.videos_checked_out_count += 1
# decrease the video's available_inventory by one (videos)
video.available_inventory -= 1
# create a due date. The rental's due date is the seven days from the current date.
#https://stackoverflow.com/questions/8196434/rails-datetime-now-without-time
due_date = (DateTime.current.to_date) + 7
#puts due_date

#create rental object
rental = Rental.new
rental.customer_id = customer_id
rental.video_id = video_id
rental.check_out = DateTime.current.to_date
rental.due_date = due_date

#if rental is able to save, then also save customer and video
#if rental does not save, then customer and video don't save
#helps DB stay in sync
if rental.save #save to db
customer.save #save customer object with video checked out count back to db
video.save #save video available inventory back to db
end

Choose a reason for hiding this comment

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

This code all looks good but it'd be appropriate for it to get pulled out into the rental model.

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