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

Kunzite 2 - Angie, Danica, Alejandra #7

Open
wants to merge 52 commits into
base: main
Choose a base branch
from

Conversation

adom2128
Copy link

No description provided.

adom2128 and others added 30 commits June 26, 2023 11:50
Copy link

@anselrognlie anselrognlie left a comment

Choose a reason for hiding this comment

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

A very light bit of feedback.

owner=board_data["owner"]
)
except (ValueError, KeyError):
abort(make_response(jsonify({"details": "Invalid data"}), 400))

Choose a reason for hiding this comment

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

Conceptually, the three flask functions here are at a different "layer" of the backend logic. Models are at a pretty low layer (they're far from the incoming request) while the endpoints are at a higher layer (they are aware of flask and endpoints and all that). We should try to minimize unnecessary dependencies where possible, with special emphasis on avoiding cases where a lower layer depends on a higher layer.

Remember that one of the key benefits of errors is that they allow us to separate the concerns of reporting that something has gone wrong, and resolving that situation. This lets us move the resolution code to places that have more context.

Here, we should avoid importing abort, make_response, and jsonify fromflask and not hanlde the error here. We should let the errors escape the function, and put the error handling closer to the endpoint code. This needn't be directly in and endpoint. Rather, it could be in a helper function that "lives" at the same layer as endpoints.

def get_id(entry):
return entry['board_id']

boards_response.sort(key=get_id)

Choose a reason for hiding this comment

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

Rather than using sort, we can have the database return the records in sorted order to begin with by using order_by on the Board.query .

cards_bp = Blueprint("cards", __name__, url_prefix="/cards")


@cards_bp.route("/<card_id>/like", methods=["PUT"])

Choose a reason for hiding this comment

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

This feels more like a PATCH method to me, since we're not replacing the entire resource.

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.

5 participants