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

Api cleanup #92

Merged
merged 14 commits into from
Jul 9, 2021
Merged

Api cleanup #92

merged 14 commits into from
Jul 9, 2021

Conversation

engelke
Copy link
Contributor

@engelke engelke commented Jul 2, 2021

  • replaced resource-specific method handlers with common one
  • separated database access for method to different module
  • added list sub-resource method (e.g., all donations to a campaign)
  • added tests

@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jul 2, 2021
@engelke engelke requested a review from ace-n July 2, 2021 20:59
Inadvertent rename, later restored
content-api/data/cloud_firestore.py Outdated Show resolved Hide resolved
content-api/data/cloud_firestore.py Show resolved Hide resolved
content-api/data/cloud_firestore.py Show resolved Hide resolved
content-api/data/cloud_firestore.py Outdated Show resolved Hide resolved
content-api/data/cloud_firestore.py Outdated Show resolved Hide resolved
content-api/main.py Show resolved Hide resolved
content-api/main_test.py Show resolved Hide resolved
content-api/resources/methods.py Show resolved Hide resolved
content-api/resources/methods.py Show resolved Hide resolved
docs/resource.json Outdated Show resolved Hide resolved
@engelke engelke requested a review from ace-n July 9, 2021 22:25
return None

resource = snapshot_to_resource(resource_snapshot)
resource = canonical_resource(resource, resource_kind, resource_fields)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: reusing the same variable is a tad confusing IMO. Should we combine these into one statement, as on lines 70-72?

resource_reference = client.document("{}/{}".format(resource_kind, id))

@firestore.transactional
def update_in_transaction(transaction, resource_reference, representation):
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah - I was wondering if we could somehow call that out in the name of this method.

(I'm not sure if there's a Python convention for that though. If not, then we can probably leave it as-is.)

snapshot_to_resource(resource_snapshot), resource_kind, resource_fields
)

if match_etag is not None: # Only apply if resource has not changed
Copy link
Contributor

Choose a reason for hiding this comment

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

This code is used in multiple places; I was thinking we could move it into a single place.

@engelke engelke merged commit 61561c7 into main Jul 9, 2021
@engelke engelke deleted the api_cleanup branch July 9, 2021 23:24
engelke added a commit that referenced this pull request Jul 12, 2021
* Markdown API docs

* Refactored all resource methods to one package

* Restored accidentally deleted resources/base

* Partial separation of db access from methods

* DB separated from method handlers

* Added first test

* More tests

* API functionally complete per current spec

* Reformatted by black

* Delete ,

Inadvertent rename, later restored

* Address PR #92 comments

* Used existing helper method more often

* Respond to PR review
engelke added a commit that referenced this pull request Jul 16, 2021
* Api cleanup (#92)

* Markdown API docs

* Refactored all resource methods to one package

* Restored accidentally deleted resources/base

* Partial separation of db access from methods

* DB separated from method handlers

* Added first test

* More tests

* API functionally complete per current spec

* Reformatted by black

* Delete ,

Inadvertent rename, later restored

* Address PR #92 comments

* Used existing helper method more often

* Respond to PR review

* Unit tests (#94)

* Unit tests

* Adding directory

* Using alpine image and installing pytest

* Using slim image instead

* Adding descriptive ID's for the steps

* productivity(terraform): correct terraform violations via PR suggestions (#98)

* productivity(terraform): correct terraform violations via PR suggestions (fixes #50)

* Switch to secrets.GITHUB_TOKEN

Co-authored-by: Dina Graves Portman <dinagraves@google.com>

Co-authored-by: Dina Graves Portman <dinagraves@google.com>

* Update decisions.md (#108)

New decision record

* Terraform and setup.sh (#93)

Initial terraform setup.

Co-authored-by: Dina Graves Portman <dinagraves@google.com>
Co-authored-by: Adam Ross <adamross@google.com>
engelke added a commit that referenced this pull request Jul 16, 2021
* OpenAPI spec and generated Python library

* More operations in spec

* Api cleanup (#92) (#101)

* Markdown API docs

* Refactored all resource methods to one package

* Restored accidentally deleted resources/base

* Partial separation of db access from methods

* DB separated from method handlers

* Added first test

* More tests

* API functionally complete per current spec

* Reformatted by black

* Delete ,

Inadvertent rename, later restored

* Address PR #92 comments

* Used existing helper method more often

* Respond to PR review

* OpenAPI complete, not finished

* Client library generated

* Update branch to match main (#113)

* Api cleanup (#92)

* Markdown API docs

* Refactored all resource methods to one package

* Restored accidentally deleted resources/base

* Partial separation of db access from methods

* DB separated from method handlers

* Added first test

* More tests

* API functionally complete per current spec

* Reformatted by black

* Delete ,

Inadvertent rename, later restored

* Address PR #92 comments

* Used existing helper method more often

* Respond to PR review

* Unit tests (#94)

* Unit tests

* Adding directory

* Using alpine image and installing pytest

* Using slim image instead

* Adding descriptive ID's for the steps

* productivity(terraform): correct terraform violations via PR suggestions (#98)

* productivity(terraform): correct terraform violations via PR suggestions (fixes #50)

* Switch to secrets.GITHUB_TOKEN

Co-authored-by: Dina Graves Portman <dinagraves@google.com>

Co-authored-by: Dina Graves Portman <dinagraves@google.com>

* Update decisions.md (#108)

New decision record

* Terraform and setup.sh (#93)

Initial terraform setup.

Co-authored-by: Dina Graves Portman <dinagraves@google.com>
Co-authored-by: Adam Ross <adamross@google.com>

Co-authored-by: Dina Graves Portman <dinagraves@google.com>
Co-authored-by: Adam Ross <adamross@google.com>
grayside pushed a commit that referenced this pull request Jul 22, 2021
* Markdown API docs

* Refactored all resource methods to one package

* Restored accidentally deleted resources/base

* Partial separation of db access from methods

* DB separated from method handlers

* Added first test

* More tests

* API functionally complete per current spec

* Reformatted by black

* Delete ,

Inadvertent rename, later restored

* Address PR #92 comments

* Used existing helper method more often

* Respond to PR review
grayside added a commit that referenced this pull request Jul 22, 2021
* OpenAPI spec and generated Python library

* More operations in spec

* Api cleanup (#92) (#101)

* Markdown API docs

* Refactored all resource methods to one package

* Restored accidentally deleted resources/base

* Partial separation of db access from methods

* DB separated from method handlers

* Added first test

* More tests

* API functionally complete per current spec

* Reformatted by black

* Delete ,

Inadvertent rename, later restored

* Address PR #92 comments

* Used existing helper method more often

* Respond to PR review

* OpenAPI complete, not finished

* Client library generated

* Update branch to match main (#113)

* Api cleanup (#92)

* Markdown API docs

* Refactored all resource methods to one package

* Restored accidentally deleted resources/base

* Partial separation of db access from methods

* DB separated from method handlers

* Added first test

* More tests

* API functionally complete per current spec

* Reformatted by black

* Delete ,

Inadvertent rename, later restored

* Address PR #92 comments

* Used existing helper method more often

* Respond to PR review

* Unit tests (#94)

* Unit tests

* Adding directory

* Using alpine image and installing pytest

* Using slim image instead

* Adding descriptive ID's for the steps

* productivity(terraform): correct terraform violations via PR suggestions (#98)

* productivity(terraform): correct terraform violations via PR suggestions (fixes #50)

* Switch to secrets.GITHUB_TOKEN

Co-authored-by: Dina Graves Portman <dinagraves@google.com>

Co-authored-by: Dina Graves Portman <dinagraves@google.com>

* Update decisions.md (#108)

New decision record

* Terraform and setup.sh (#93)

Initial terraform setup.

Co-authored-by: Dina Graves Portman <dinagraves@google.com>
Co-authored-by: Adam Ross <adamross@google.com>

Co-authored-by: Dina Graves Portman <dinagraves@google.com>
Co-authored-by: Adam Ross <adamross@google.com>
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

2 participants