-
Notifications
You must be signed in to change notification settings - Fork 61
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
Api cleanup #92
Conversation
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
content-api/data/cloud_firestore.py
Outdated
return None | ||
|
||
resource = snapshot_to_resource(resource_snapshot) | ||
resource = canonical_resource(resource, resource_kind, resource_fields) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
* 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
* 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>
* 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>
* 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 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>