Skip to content

Alice and Hannah - VideoStoreAPI#6

Open
hertweckhr1 wants to merge 43 commits intoAda-C10:masterfrom
hertweckhr1:master
Open

Alice and Hannah - VideoStoreAPI#6
hertweckhr1 wants to merge 43 commits intoAda-C10:masterfrom
hertweckhr1:master

Conversation

@hertweckhr1
Copy link

Video Store API

Congratulations! You're submitting your assignment!
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.

Comprehension Questions

Question Answer
Explain how you came up with the design of your ERD, based on the seed data. Rentals seed data have foreign keys so we knew that customers would have many rentals and movies would have many rentals, so rentals would belong to both.
What would be the Big-O time complexity of your /customers & /movies endpoints? What does the time complexity depend on? Explain your reasoning. O(n) because we are looping through every customer and movie. When we sort using ruby methods, it would be n log n because we are using a type of quick sort. We are unsure of time complexity when using database sql commands, but we did look it up and could not find clear answer.
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 loop through the movies, then customers, and then rentals. We believe this is O(n) because we loop through each one of these separately. Again we do not know exact time complexity using db operations.
Describe a set of positive and negative test cases you implemented for a model. In movies controller we tested available? to see if the movie was available to checkout. Positive: We returned true if available inventory is greater than 0. Negative: we returned false if available inventory is 0.
Describe a set of positive and negative test cases you implemented for a controller. In the rentals controller we check overdue rentals. Positive: it will return all overdue items that have not been checked in and the due date has passed. Negative: we make sure it will render the empty json view explaining no records found when there are no overdue rentals.
How does your API respond when bad data is sent to it? We make it look really pretty and customize responses with rabl to let our customers know more specifically what they did wrong. We have such views like bad request, notfound, empty array, and denied to explain all possible cases.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. In the customer model we wrote a method called "overdue_items?" This checks to see if a the rental checkin_date is equal to nil and if the rental due date is before the current date. If we get any overdue items we return true, otherwise we return false. This helps clean up our rentals controller so the business logic to test checkout is not in the controller.
Do you have any recommendations on how we could improve this project for the next cohort? We felt like we had a lot of project time this week, but we did not need as much time to complete project. We would like to start Javascript sooner.
Link to Trello https://www.lucidchart.com/invitations/accept/be102190-f263-425e-b86c-5ceac70a1076
Link to ERD https://trello.com/b/rt1Kkr6q/hannah-alices-videostoreapi
Summary

hertweckhr1 and others added 30 commits November 5, 2018 12:50
…dex, added rabl gem and added forgery protection to controllers
…ts for overdue items and available_inventory
@CheezItMan
Copy link

Video Store

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene Good number of commits and good commit messages
Comprehension questions Check, the database operations are a little hard to judge, but you're correct.
General
Business Logic in Models Check
All required endpoints return expected JSON data Check
Requests respond with appropriate HTTP Status Code Check
Errors are reported Check
Testing
Passes all Smoke Tests check
Model Tests - all relations, validations, and custom functions test positive & negative cases Check, but you have one failing test
Controller Tests - URI parameters and data in the request body have positive & negative cases Check, but you have a couple of failing tests.
Overall Pretty good job, you hit all the learning goals. You should use ERB tags in the fixtures to prevent the due dates you have hardcoded now, from causing tests to fail in the future. Otherwise excellent job.

movie = movies(:movieone)
starting_inventory = movie.available_inventory

expect {

Choose a reason for hiding this comment

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

This test is failing because this customer has overdue items and so is forbidden from checking out a movie.

Choose a reason for hiding this comment

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

Fixed! The Date.tomorrow for customer one in the yml file fixed everything.

end

it "returns false if customer has no overdue items" do
expect(customer.overdue_items?).must_equal false

Choose a reason for hiding this comment

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

This test is failing, because this customer has an item which was due yesterday. If you want to fix this, I would use erb tags to set the due date to Date.tomorrow, so it would never be overdue.

Choose a reason for hiding this comment

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

Ah! Totally forgot about these dates. Fixed!


body = JSON.parse(response.body)
expect(body).must_be_kind_of Array
expect(body.length).must_equal 1

Choose a reason for hiding this comment

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

This test is failing, because this customer has two overdue movies.

Choose a reason for hiding this comment

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

Fixed!

@customers = sort_and_paginate(sort_options, list, params)
end

def zomg

Choose a reason for hiding this comment

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

😀

@@ -0,0 +1,92 @@
class ApplicationController < ActionController::API

Choose a reason for hiding this comment

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

I like the helper methods you put in here.

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