-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bulk): implement bulk gets of multiple uuids
- Loading branch information
Showing
8 changed files
with
100 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,3 +65,6 @@ docs/_build/ | |
local_settings.py | ||
settings.yaml | ||
*.sq3 | ||
|
||
# swagger | ||
swagger-codegen-cli-2.3.1.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"""Bulk operations for indexd""" | ||
import json | ||
|
||
import flask | ||
|
||
from indexd.errors import UserError | ||
from indexd.index.drivers.alchemy import IndexRecord | ||
|
||
blueprint = flask.Blueprint('bulk', __name__) | ||
|
||
blueprint.config = dict() | ||
blueprint.index_driver = None | ||
|
||
|
||
@blueprint.route('/bulk/documents', methods=['POST']) | ||
def bulk_get_documents(): | ||
""" | ||
Returns a list of records. | ||
""" | ||
ids = flask.request.json | ||
if not ids: | ||
raise UserError('No ids provided') | ||
if not isinstance(ids, list): | ||
raise UserError('ids is not a list') | ||
|
||
with blueprint.index_driver.session as session: | ||
query = session.query(IndexRecord) | ||
query = query.filter(IndexRecord.did.in_(ids)) | ||
|
||
docs = [q.to_document_dict() for q in query] | ||
return json.dumps(docs), 200 | ||
|
||
|
||
@blueprint.record | ||
def get_config(setup_state): | ||
config = setup_state.app.config['INDEX'] | ||
blueprint.index_driver = config['driver'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters