Skip to content

Time - Kate P + Jessica L#6

Open
jesshliang wants to merge 47 commits intoAda-C13:masterfrom
jesshliang:master
Open

Time - Kate P + Jessica L#6
jesshliang wants to merge 47 commits intoAda-C13:masterfrom
jesshliang:master

Conversation

@jesshliang
Copy link

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 Initially, we decided on two models, Customer and Video. But we ended a third, Rental, after looking at the API endpoints. We further added new columns to Customer for number of videos checked out.
What would be the Big-O time complexity of your /customers & /videos endpoints? What does the time complexity depend on? Explain your reasoning. These endpoints involved getting ALL videos/customers and then further ordering them by name or title. The Big-O would then be dependent on how the ordering is done. Assuming Ruby does merge sort or something similarly efficient, the Big-O would be O(n log n).
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. This endpoint involves searching for a Rental based on two parameters, the customer id and the video id. The Big-O would again be dependent on how the search is done when using the method 'find_by'. We assume Ruby would use the most efficient search method, but at worst the complexity would be O(n^2), nesting loops to search both params, and at best, O(n), with the method returning the first result matching both parameters at once.
Describe a specific set of positive and negative test cases you implemented for a model. We tested validations for our models, such as Rental. We tested a positive case, where all fields are provided, and a negative case, where one of the fields is missing.
Describe a specific set of positive and negative test cases you implemented for a controller. We tested methods for checking in and checking out a Rental. We tested positive cases, where the Rental is successfully checked in or out, as well as negative cases, where customer or video were not found.
Broadly, describe how an API should respond when it handles a request with invalid/erroneous parameters. It should respond with a specific error code and information about the error if possible.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We wrote methods for increasing and decreasing customer's videos checked out and video's availability. We chose to make these functionalities into model methods, because it should be considered business logic and does not have anything to do with routing.

Copy link

@kaidamasaki kaidamasaki left a comment

Choose a reason for hiding this comment

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

Great job! I really don't have very many notes on your project, it was very clean and well implemented. 😃


if rental.save
customer.check_out_increase
customer.save

Choose a reason for hiding this comment

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

This is a redundant save.

(check_out_increase already saves the model.)

@kaidamasaki
Copy link

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 Business logic in the controller.
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 ✔️
Yellow (Approaches Standards) 2+ in Code Review && 1+ in Functional Requirements, or the instructor judges that this project needs special attention
Red (Not at Standard) 0-1 in Code Review or 0 in Functional Reqs, or assignment is breaking/doesn’t run with less than 5 minutes of debugging, or the instructor judges that this project needs special attention

Comprehension Questions

These endpoints involved getting ALL videos/customers and then further ordering them by name or title. The Big-O would then be dependent on how the ordering is done. Assuming Ruby does merge sort or something similarly efficient, the Big-O would be O(n log n).

This is a O(n * log(n)) operation if you do not have an index (since the database uses an efficient sort). If you created an index via a migration though then it would become a O(n) operation since the database index lets you go through a table in order in a single pass.

(If you ordered by id since there is already an index on that it would be a O(n) operation as well.)

This endpoint involves searching for a Rental based on two parameters, the customer id and the video id. The Big-O would again be dependent on how the search is done when using the method 'find_by'. We assume Ruby would use the most efficient search method, but at worst the complexity would be O(n^2), nesting loops to search both params, and at best, O(n), with the method returning the first result matching both parameters at once.

This is a good intuition. However databases can do even better than O(n) here. Because of how databases store keys (in a tree, specifically a B-Tree) searching for a foreign key with an index on it will be O(log(n)).

This is why it's important to add a reference in your migrations in addition to just adding a has_many or belongs_to in your model!

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

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