Skip to content

Conversation

@MiraMarshall
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. We decided to make a Customers Model, Movie Model and have a Rental Model that joined both the customer_id and movied_id.
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) time complexity depends on the amount of data in the data structure.
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(log(n)) with time complexity depending on how long it takes to use the find_by.
Describe a set of positive and negative test cases you implemented for a model. We have positive and negative test cases for with and without validations.
Describe a set of positive and negative test cases you implemented for a controller. We implemented positive and negative test cases for the show methods in all of our controllers.
How does your API respond when bad data is sent to it? It renders a 404 with an error message.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. They aren't model methods, but we made a custom method for check-in and check-out to track inventory and create rentals.
Do you have any recommendations on how we could improve this project for the next cohort? We would suggest not having a partner project directly after a 4 person project. So people can have some time to reset after bEtsy. More organized instructions and a little more time working with Postman.
Link to Trello https://trello.com/b/pv6LNLTC/videostoreapi
Link to ERD
Summary Overval it was a great activity getting to know people from the other class. It was making an API. It reminded us that we need to study relationships.

@dHelmgren
Copy link

Video Store

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene good
Comprehension questions good. Need for a break after bEtsy noted.
General
Business Logic in Models All of your business logic is in your models, see comment on how this could be fixed.
All required endpoints return expected JSON data Yes
Requests respond with appropriate HTTP Status Code yes
Errors are reported yes
Testing
Passes all Smoke Tests yes
Model Tests - all relations, validations, and custom functions test positive & negative cases Given that you didn't have logic in your models, these tests covered your cases.
Controller Tests - URI parameters and data in the request body have positive & negative cases No, see comments.
Overall This project could have gone better. Doing all of the work of your application in the controller makes a lot of pieces of your app very hard to test, but on top of that the tests that you submitted don't cover many important cases that your app should handle. TDD is part of the Ada bar, so make sure that future projects cover all applicable cases.

def show
customer = Customer.find_by(id: params[:id])
if customer
render status: :ok, json: customer.as_json(only: [:id, :name, :registered_at, :adress, :city, :state, :postal_code, :phone, :movies_checked_out_count]), status: :ok

Choose a reason for hiding this comment

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

Small style note: not all text editors wrap lines for you. This line is so long that on GitHub I have to scroll horizontally to see all the pieces. You can make this easier to read by putting a newline after any given comma in a statement.

if customer
render status: :ok, json: customer.as_json(only: [:id, :name, :registered_at, :adress, :city, :state, :postal_code, :phone, :movies_checked_out_count]), status: :ok
else
render status: :not_found, json: { ok: false, messages: "Movie was not found!" }

Choose a reason for hiding this comment

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

This is a customer... Copy pasta is dangerous!

def check_out
rental = Rental.new(rental_params)
customer = Customer.find_by(id: rental.customer_id)
movie = Movie.find_by(id: rental.movie_id)

Choose a reason for hiding this comment

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

You have a bunch of business logic here! Would it be possible to encapsulate this in a model method? Something like

rental.check_out(customer_id, movie_id)

might be a good interface. That would make this logic easier to test as well.


it "returns json" do
get customers_path
expect(response.header["Content-Type"]).must_include "json"

Choose a reason for hiding this comment

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

This isn't checking the actual JSON to see if the contents are correct.

get movies_index_url
value(response).must_be :successful?
end

Choose a reason for hiding this comment

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

What about the show action?

due_date: Date.today + 7,
}
}
describe "checkout" do

Choose a reason for hiding this comment

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

These tests don't cover cases I would expect to see. What if there is bad data? What data is being sent back?

Also, I don't see any tests written for the checkin route.

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