Skip to content

Earth - Genevieve & Maha#11

Open
geneminde wants to merge 34 commits intoAda-C14:masterfrom
geneminde:master
Open

Earth - Genevieve & Maha#11
geneminde wants to merge 34 commits intoAda-C14:masterfrom
geneminde:master

Conversation

@geneminde
Copy link

@geneminde geneminde 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 used the information in the seed data and the endpoint requirements to construct models that allowed us to return the required information as well as reflect our underlying assumptions around what "videos", "customers" and "rentals" would do in a real-life context.
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 have O(n) time complexity where n is the number of customers (or videos - we did not implement a '/videos' endpoint per the project requirements). This is because the returned Customer object is parsed into json and this process depends on the number of customer in Customer.all.
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 checkin endpoint does several queries to locate customers or videos - these have O(n) time complexity where n is the number of records in each table. Overall, we would expect this endpoint to exhibit O(n) time complexity.
Describe a specific set of positive and negative test cases you implemented for a model. For the customers model, we wrote a positive case where a model has all the required attributes for validation along with test cases for each specific failure case (ie - a customer without an address present).
Describe a specific set of positive and negative test cases you implemented for a controller. For the checkout endpoint, we wrote a positive test case where a video was successfully checked out to a customer (available inventory was decremented, the customer's rental count was incremented, and a new rental was created with a valid due date). A negative test case was one where a request was submitted without a valid customer id. In this case, no rental was created and the response contained the appropriate error messages.
Broadly, describe how an API should respond when it handles a request with invalid/erroneous parameters. The response should include useful error messages, communicating why the request failed along with the appropriate status.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We wrote a method in the Rental model to validate that the date the record was created cannot be greater than the return date (meaning that a video cannot be checked in prior to being checked out.)

Maha-ElMais and others added 30 commits December 1, 2020 15:29
video controller + model validation tests
generated customers controller, index actions, and routes.
Implement Rentals Controller + Tests
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 ✔️
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 💚 Niiice!

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

Summary

Very well done you two. Excellent submission.

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

post 'rentals/check-out', to: 'rentals#checkout'
post 'rentals/check-in', to: 'rentals#checkin'

resources :customers, only: [:index]

Choose a reason for hiding this comment

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

👍

Comment on lines +4 to +11
validates :name, presence: true
validates :registered_at, presence: true
validates :postal_code, presence: true
validates :phone,presence: true
validates :videos_checked_out_count, numericality: { :only_integer => true, greater_than_or_equal_to: 0 }
validates :address, presence: true
validates :city, presence: true
validates :state,presence: true

Choose a reason for hiding this comment

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

Good set of validations

@@ -0,0 +1,28 @@
class Rental < ApplicationRecord

Choose a reason for hiding this comment

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

Good validations and nice business logic methods

customer: customer_one
video: black_widow
due_date: "2021-12-12"
created_at: <%= 5.days.ago.to_s(:db) %>

Choose a reason for hiding this comment

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

Neat!

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