Skip to content

Tram & Schanen -Video Store API#33

Open
schanenR wants to merge 51 commits intoAda-C14:masterfrom
schanenR:master
Open

Tram & Schanen -Video Store API#33
schanenR wants to merge 51 commits intoAda-C14:masterfrom
schanenR:master

Conversation

@schanenR
Copy link

@schanenR schanenR commented Dec 4, 2020

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 The seed data revealed all of the fields we should expect to add to customer and video databases. We used the endpoints to inform our relationships between Customer, Video & Rental.
What would be the Big-O time complexity of your /customers & /videos endpoints? What does the time complexity depend on? Explain your reasoning. The index actions are On time complexity because the iterate through every instance of the class. The video show action used the find_by method which could be On or O1, we could not find a definitive answer but found it uses where().take. The video create action is O1.
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. The rentals check-in is On or O1 (for the same confusion around the video show endpoints). The time complexity depends on the finding a rental after looking up a customer and video by id's.
Describe a specific set of positive and negative test cases you implemented for a model. Does the class instantiate when not all of the needed fields are present or when one of the required fields are nil? Does the new video initialize with a valid inventory count?
Describe a specific set of positive and negative test cases you implemented for a controller. For the check-in controller action I tested to ensure the correct fields of the returned and pared JSON. I tested the action for the correct 'not-found' error message if the video could not be located in order to check-in the correct rental.
Broadly, describe how an API should respond when it handles a request with invalid/erroneous parameters. It should respond with bad_request when given invalid parameters and display related errors as JSON.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We did have custom methods for incrementing and decrementing the available_inventory and video_check_out_count but removed them and instead used the build in Ruby methods in our controller actions for check-in and check-out.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

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 ✔️, although you should move more check-in check-out business logic into the 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 💚

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
Logical/Organized

Summary

Nice work, you both hit the learning goals here. I do like your tests a lot. Well done.

Comment on lines +4 to +8
resources :customers, only: [:index]
resources :videos, only: [:index, :show, :create]

post '/rentals/check-out', to: 'rentals#check_out', as: "check_out"
post '/rentals/check-in', to: 'rentals#check_in', as: "check_in"

Choose a reason for hiding this comment

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

👍

@@ -0,0 +1,13 @@
class Video < ApplicationRecord

Choose a reason for hiding this comment

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

It would make sense to have a checkout_video method instead of doing that logic in the controller.

Comment on lines +8 to +10
def show

end

Choose a reason for hiding this comment

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

Suggested change
def show
end

before_action :find_customer
before_action :find_video

def check_out

Choose a reason for hiding this comment

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

These methods are a bit long, maybe creating a check-out and check-in methods for the model-level.

Comment on lines +3 to +4
before_action :find_customer
before_action :find_video

Choose a reason for hiding this comment

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

Good filters

end
end

describe "validations" do

Choose a reason for hiding this comment

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

Really good validation checks

expect(found_rental.video.available_inventory).must_equal start_inventory_count - 1
expect(end_count).must_equal start_inventory_count - 1
end
# TODO: negative or edge test case?

Choose a reason for hiding this comment

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

Well at least you're noteing this. No test to make sure the inventory can't go below 0

# TODO: negative or edge test case?
end

describe "increase_videos_checked_out" do

Choose a reason for hiding this comment

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

What about a test to see if more videos can be checked out than you have in inventory.

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

Comments