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

Straw man for approvers resource #14

Merged
merged 9 commits into from
Jun 14, 2021
Merged

Straw man for approvers resource #14

merged 9 commits into from
Jun 14, 2021

Conversation

engelke
Copy link
Contributor

@engelke engelke commented May 20, 2021

No description provided.

@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label May 20, 2021
@engelke
Copy link
Contributor Author

engelke commented May 20, 2021

Addresses issue #12

@engelke engelke requested a review from grayside May 20, 2021 23:32


@app.route('/approvers/', defaults={'approver': None}, methods=['GET', 'POST'])
@app.route('/approvers/<string:approver>', methods=['GET', 'PUT', 'DELETE', 'PATCH'])
Copy link
Contributor

Choose a reason for hiding this comment

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

May I suggest breaking this up into different functions for testability / readability? eg

@app.route('/approvers/<string:approver>', methods=['GET'])
def get_approvers(approver):
    if approver is None:
        return approvers.list()

    return approvers.get(approver)


@app.route('/approvers/<string:approver>', methods=['POST'])
def post_approvers(approver):
    . . .
    return approvers.insert(body)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's testable as is, but it's sure a lot less readable than it could be. Will be doing this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

More readable now.

Copy link
Collaborator

@grayside grayside left a comment

Choose a reason for hiding this comment

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

Requesting changes to ensure as a group we have further discussion about Cloud Run vs. Cloud Functions and Firestore vs. Cloud SQL before merging.

content-api/server/Dockerfile Show resolved Hide resolved
content-api/server/resources/approvers.py Show resolved Hide resolved
content-api/server/resources/approvers.py Outdated Show resolved Hide resolved
content-api/server/main.py Show resolved Hide resolved
Copy link
Collaborator

@grayside grayside left a comment

Choose a reason for hiding this comment

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

Thanks for responding to my feedback @engelke. My takeaway is that the term strawman here is presenting this change as a "pretotype v2" for the API. In that light, the code and decisions made here are not intended as a first iteration: the lessons we're learning here are about the API design and learning how the website will integrate with this backend.

content-api/server/Dockerfile Show resolved Hide resolved
@engelke engelke merged commit 7db66bf into main Jun 14, 2021
@engelke engelke deleted the api-dummy branch June 14, 2021 22:08
grayside pushed a commit that referenced this pull request Jul 22, 2021
* Straw man for approvers resource

* Prepare for generic resource handling

* More readable, ready for another resource

* Reuse cached firestore client

* Instructions to run locally

* Handle invalid resource names

* Add donors resource

* Let black format this code

* Enforce optional etag matching
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants