Skip to content

Conversation

@codesrobertson
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 seed data and drew out an ERD from the fields present (adding necessary ones as we went for the functionalities we wanted).
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 represents the customers and videos and n being the time to populate.
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. Using find_by should keep it O(n).
Describe a specific set of positive and negative test cases you implemented for a model. For videos, we returned a 404 request for a non-existent video as a negative test case, and returned a new video for a video being added to the database.
Describe a specific set of positive and negative test cases you implemented for a controller. For rentals, we implemented a "enables customer to checkout" positive test, and a "customer cannot checkout if given an invalid video_id" negative test.
Broadly, describe how an API should respond when it handles a request with invalid/erroneous parameters. It should notify the user with an error message and some JSON.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. For customer, we chose to wrap the logic or increment and decrement checkout_out_count into methods because it was DRYer than not doing so, and easier to access.

codesrobertson and others added 30 commits May 27, 2020 14:20
@kaidamasaki
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

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

Copy link

@kaidamasaki kaidamasaki left a comment

Choose a reason for hiding this comment

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

Great job! I left a few comments but honestly don't have too much to say, your solution was really solid. 😃

class Customer < ApplicationRecord
has_many :rentals

validates :id, presence: true

Choose a reason for hiding this comment

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

Requiring id to be present means that you can't rely on auto-assignment of IDs and breaks db:seed.

This isn't something you'd catch without doing a rails db:reset or something though, just something to keep in mind in the future.

Comment on lines +8 to +11
def update_check_out_dates
self.check_out_date = Date.today
self.due_date = Date.today + 7
end

Choose a reason for hiding this comment

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

It's confusing that this method doesn't save but your other update methods do.

Suggested change
def update_check_out_dates
self.check_out_date = Date.today
self.due_date = Date.today + 7
end
def update_check_out_dates
self.check_out_date = Date.today
self.due_date = Date.today + 7
return self.save
end

Comment on lines +6 to +12
if @video.nil? || @customer.nil?
render json: {
errors: ['Not Found'],
}, status: :not_found

return
end

Choose a reason for hiding this comment

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

Since you repeat this logic I'd probably move it into find_video_and_customer as well.

Comment on lines +7 to +19
let(:customer) {
customers(:pengsoo)
}
let(:video) {
videos(:parasite)
}

let(:rental_data) {
{
customer_id: customer.id,
video_id: video.id
}
}

Choose a reason for hiding this comment

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

Nice use of let. 😃

}

before do # important!
post check_out_path, params: rental_params

Choose a reason for hiding this comment

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

I would probably have directly created the Rental instead of posting but that's mostly a stylistic choice.

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