Skip to content

Conversation

@antoniairizarry
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 went over the project requirements and files individually and then shared and compared our thoughts, which we both had written on notebooks. Our ERDs were very similar and, though we discussed alternative designs, we kept it mostly the same through the process. We did have to create additional migrations for columns we needed as we were going along.
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) because it would need to go through each of the customers/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 would also need to go through each of the IDs for customers/videos.
Describe a specific set of positive and negative test cases you implemented for a model. We tested validations in the customer and videos and checked for required fields, if they were there or nil.
Describe a specific set of positive and negative test cases you implemented for a controller. We checked that videos controller returned a hash with the proper fields for its show action and if it returned a 404 request if the video was nonexistent.
Broadly, describe how an API should respond when it handles a request with invalid/erroneous parameters. An API should respond with a 404 status code (not_found) or 400 status code (bad request).
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We made methods dealing with video inventory in the video model. When a method does “business logic”/calculate something it should be placed within corresponding model files.

antoniairizarry and others added 30 commits May 26, 2020 12:49
FreeMonkey19 and others added 27 commits May 27, 2020 22:49
…ypo in migrations during setup. No other changes were made to tests. All smoke tests pass now
@antoniairizarry
Copy link
Author

NOTE: Because of an initial error in our migrations which we were told would be better left alone, we changed "video_id" in the Wave 2 smoke tests to "videos_id" which helped us to get them to pass. Dee told us this was okay, and they were aware of the initial typo because they helped us troubleshoot some earlier issues, as well as some issues in the end. That is the only modification we made to those tests.

@CheezItMan
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 ⚠ See my notes on the check-in and check-out logic.

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

Summary

Note for the comprehension questions that the time complexity of check-in could be O(1) if the check-in action has the id of the rental to check in, as it can look up things directly. You also need to work much more on testing, both model and controller testing. See my inline comments, but the biggest problem is that you aren't covering the edge cases around the check-in and check-out logic. Further you don't have much model testing. That's a bit problematic and I highly encourage you to focus on through testing in the bEtsy project.

That said you do satisfy the requirements so this is a green result.

return
end

if rental.save

Choose a reason for hiding this comment

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

What about if rental.save returns false? You should have some kind of response with an error response code here.

}, status: :not_found
return
end
render json: video.as_json(only: [:title, :overview, :release_date, :total_inventory, :available_inventory])

Choose a reason for hiding this comment

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

Status code?

Comment on lines +7 to +15
def decrease_inventory
self.available_inventory -= 1
self.save
end

def increase_inventory
self.available_inventory += 1
self.save
end

Choose a reason for hiding this comment

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

This works, but I would suggest instead writing a method to check the available inventory by the number checked out and the number total, rather than make a separate field for available inventory.

describe CustomersController do
CUSTOMER_FIELDS = ["id", "name", "registered_at", "postal_code", "phone", "videos_checked_out_count"].sort

it "must get index" do

Choose a reason for hiding this comment

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

👍 Good index tests


describe RentalsController do

describe "index" do

Choose a reason for hiding this comment

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

You should also have a test when there are no rentals.

@@ -0,0 +1,18 @@
require "test_helper"

describe Video do

Choose a reason for hiding this comment

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

Noting that you only have validations tests and only one really at that...

@@ -0,0 +1,10 @@
Rails.application.routes.draw do

Choose a reason for hiding this comment

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

👍 Well done


# Act
get customers_path

Choose a reason for hiding this comment

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

response code test?

end
end # describe index end

describe "check_out" do

Choose a reason for hiding this comment

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

You should also test what happens if you check out more copies than are in the inventory...

end # describe check-out end


describe "check_in" do

Choose a reason for hiding this comment

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

What happens when you check-in a video which isn't currently checked out?

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