-
Notifications
You must be signed in to change notification settings - Fork 27
Time - Hannah J. and Alex #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Add customer fields
Video Store APIMajor Learning Goals/Code Review
Functional Requirements
Overall Feedback
Code Style Bonus AwardsWas the code particularly impressive in code style for any of these reasons (or more...?)
|
kaidamasaki
left a comment
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
| def update_check_out_dates | ||
| self.check_out_date = Date.today | ||
| self.due_date = Date.today + 7 | ||
| end |
There was a problem hiding this comment.
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.
| 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 |
| if @video.nil? || @customer.nil? | ||
| render json: { | ||
| errors: ['Not Found'], | ||
| }, status: :not_found | ||
|
|
||
| return | ||
| end |
There was a problem hiding this comment.
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.
| let(:customer) { | ||
| customers(:pengsoo) | ||
| } | ||
| let(:video) { | ||
| videos(:parasite) | ||
| } | ||
|
|
||
| let(:rental_data) { | ||
| { | ||
| customer_id: customer.id, | ||
| video_id: video.id | ||
| } | ||
| } |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
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
/customers&/videosendpoints? What does the time complexity depend on? Explain your reasoning.POST /rentals/check-inendpoint? What does the time complexity depend on? Explain your reasoning.