Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spruce - C16 - Symone & Vange #51

Open
wants to merge 42 commits into
base: master
Choose a base branch
from

Conversation

HouseOfVange
Copy link

No description provided.

Copy link

@audreyandoy audreyandoy left a comment

Choose a reason for hiding this comment

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

Great work Symone and Vange! Y'all met all the learning goals for this project and passed all the tests. Y'all did a great job practicing the single responsibility principle when it came to defining routes.

I provided feedback on how y'all can refactor by omitting redundant logic and reorganizing your project.

Project grade: Green 🟢 !

@@ -32,5 +32,10 @@ def create_app(test_config=None):
migrate.init_app(app, db)

#Register Blueprints Here

from .routes import customers_bp, videos_bp, rentals_bp

Choose a reason for hiding this comment

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

👍

Comment on lines +5 to +10
name = db.Column(db.String)
postal_code = db.Column(db.String)
phone = db.Column(db.String)
registered_at = db.Column(db.DateTime())
videos = db.relationship("Video", secondary="rental", backref="customers")

Choose a reason for hiding this comment

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

At the moment, any of these columns can contain null values. Consider revisiting each column to determine which column should truly have null values versus not. For example, is it useful to store a Customer without a name or phone number? Those two columns can be considered required information to store about a customer, despite our requirements not strictly describing that behavior.

Comment on lines +4 to +20
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
title = db.Column(db.String)
release_date = db.Column(db.DateTime())
total_inventory = db.Column(db.Integer)

def to_dict(self):
return {
"id": self.id,
"title" : self.title,
"release_date" : self.release_date,
"total_inventory" : self.total_inventory
}

@classmethod
def from_dict(cls, values):
return cls(**values)

Choose a reason for hiding this comment

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

The same comment about required information for Customer can also be applied to Video and Rental.

@@ -0,0 +1,413 @@
from app import db

Choose a reason for hiding this comment

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

This file is over 400 lines of code! We can refactor the overall project structure by adding the logic specific to the customer, video, and rental routes into separate files within a routes folder.

Comment on lines +20 to +26
def display_customer_info(customer):
return {
"id": customer.id,
"name": customer.name,
"postal_code": customer.postal_code,
"phone": customer.phone
}

Choose a reason for hiding this comment

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

Nice helper function. We could move this function into the Customer model and that way every instance of a Customer will have access to this method, eliminating the need to pass in the instance as a parameter.

Comment on lines +230 to +231
@videos_bp.route("/<video_id>", methods = ["DELETE"])
def delete_video(video_id):

Choose a reason for hiding this comment

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

👍

Comment on lines +265 to +269
if "customer_id" not in request_body:
return {"details": "Request body must include customer_id."}, 400

if "video_id" not in request_body:
return {"details": "Request body must include video_id."}, 400

Choose a reason for hiding this comment

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

We can combine these conditionals

Suggested change
if "customer_id" not in request_body:
return {"details": "Request body must include customer_id."}, 400
if "video_id" not in request_body:
return {"details": "Request body must include video_id."}, 400
if "customer_id" not in request_body or "video_id" not in request_body:
return {"details": "Request body must include customer_id."}, 400

return jsonify(response_body), 200


@rentals_bp.route("/check-in", methods = ["POST"])

Choose a reason for hiding this comment

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

👍

Comment on lines +365 to +366
@customers_bp.route("/<customer_id>/rentals", methods=["GET"])
def get_checked_out_videos(customer_id):

Choose a reason for hiding this comment

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

👍

Comment on lines +393 to +394
@videos_bp.route("/<video_id>/rentals", methods=["GET"])
def get_customers_by_video(video_id):

Choose a reason for hiding this comment

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

👍

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