Skip to content

Christina && Beatrice Video Store API#17

Open
Beatress wants to merge 48 commits intoAda-C14:masterfrom
Beatress:master
Open

Christina && Beatrice Video Store API#17
Beatress wants to merge 48 commits intoAda-C14:masterfrom
Beatress:master

Conversation

@Beatress
Copy link

@Beatress Beatress commented Dec 3, 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 We looked through the seed data as well as the expected output results for the SHOW actions to find the attributes. We also figured that rentals was a many-to-many model relation between videos and customers.
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 endpoints would be O(n log n) because we had to use .order() to get the smoke tests to pass. We're assuming .order() is n log n. The show endpoints would be O(1) because they are using .find_by(id: params[:id])). It should be O(1) to look up an entry from a hash key.
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. We aren't totally sure what the time complexity is, but we are guessing it's O(1). The time complexity depends on how long it takes the database to look for the rental given a customer id and video id. We are going to assume the database works like a hash table and can retrieve it in O(1)
Describe a specific set of positive and negative test cases you implemented for a model. We tested if a video was valid with an inventory of 0, but invalid with an inventory of -1
Describe a specific set of positive and negative test cases you implemented for a controller. For the check-in controller, we had a positive test case where a video was checked out then successfully checked in. For the negative case, we tried to just check in the video without it being checked out first, which didn't work.
Broadly, describe how an API should respond when it handles a request with invalid/erroneous parameters. To handle a request with invalid/erroneous parameters, an API should return an appropriate a status code that indicates a bad request (400) and a list of errors such as "Not found" or any validation errors.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. The Rental#checkout increments and decrements the customer's videos checked out count and video's available inventory. Since it's business logic that changes the database, we wrapped it into a model method instead of in the controller.

Beatress and others added 30 commits December 1, 2020 17:00
…outes for customer and replaced with resources for only index and show
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.

2 participants

Comments