Skip to content

Conversation

@ubeninja77
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 After looking at the seed model, discussed how we wanted to connect Customer and Video and decided to add a Rentals to have the has-many relationship.
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), both are dependent on the number of customer and 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) because it needs to iterate through the customer and video data but we did not implement a nested loop.
Describe a specific set of positive and negative test cases you implemented for a model. When a valid customer is able to check out a video, the number of videos they checked out increased. Negative test case is when the video is returned, the number of videos they check checked out decreases.
Describe a specific set of positive and negative test cases you implemented for a controller. Verify if a video was available to rent and responds by making a rental. Negative test case is if the video was not available; it returned Not Found.
Broadly, describe how an API should respond when it handles a request with invalid/erroneous parameters. An API should respond with either a bad_request or not_found error. Postman made sure we remembered that.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. In the rental model, we wrote a method that restored a video's availability once it's returned. We did this so that the available count of the videos reflects it's return and is able to be checked out again.

@jmaddox19
Copy link

jmaddox19 commented Jun 9, 2020

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 ✔️ Yes! So many commits with good 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 ✔️Separation is there but there is some redundancy in which model is doing what. See inline comments for more context.
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 Everything except verification of counts and inventories

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

Good work y'all! I've left a few inline comments about some things I noticed but they are just a few smaller details. If any of the comments aren't clear, please reach out to me!

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 +11 to +14
def set_videos_checked_out_count
self.customer.checked_out_video
self.videos_checked_out_count = self.customer.videos_checked_out_count
end

Choose a reason for hiding this comment

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

considering the videos_checked_out_count in rental mimics the value from the customer model, it would be safer and less work to not bother having such a value on the rental model.
This means you don't need so much code in the rental model and reduces the risk that they become mismatched somehow, introducing a bug.

Comment on lines +15 to +18
def set_available_inventory
self.video.checked_out
self.available_inventory = self.video.available_inventory
end

Choose a reason for hiding this comment

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

The same could be said here about available_inventory as I said in my comment above about videos_checked_out_count,

describe Customer do
describe "validations" do
before do
@customer = customers(:Kenji)

Choose a reason for hiding this comment

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

This isn't working for a couple reasons. I've added a code suggestion to demonstrate what it should look like to work properly.

Suggested change
@customer = customers(:Kenji)
@customer = customer(:customer_2)

Choose a reason for hiding this comment

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

However, after updating this, I still get the following error for the validation test:
NoMethodError: undefined method 'checked_out_count' for #<Array:0x00007f93a52c8130>

Choose a reason for hiding this comment

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

I'm guessing y'all were aware these were failing and just didn't have time to fix them.
In case you were unaware they were failing, I want to remind you that it's important to run tests after writing them to make sure they work and it's important to run all tests before submitted a pull request to make sure all tests pass.

Comment on lines +17 to +29
describe "custom methods" do
describe "checked_out_movie" do
it "will increase checked_out_movie by one" do
expect{ customer.checked_out_movie }.must_differ "customer.checked_out_count", 1
end
end

describe "checked_in_movie" do
it "will decrease movies_checked_out_count by one" do
expect{ customer.checked_in_movie }.must_differ "customer.checked_out_count", -1
end
end
end

Choose a reason for hiding this comment

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

These are accidentally nested within the "Validations" describe block.

expect {
post check_out_path, params: good_rental_data
}.must_differ 'Rental.count', 1
must_respond_with :created

Choose a reason for hiding this comment

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

This test fails because the controller returns :success rather than :created.
It looks like y'all divided up who was doing the test and source code for this and maybe didn't run the tests after putting them together.

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