diff options
author | Munyoki Kilyungi | 2024-04-17 15:47:23 +0300 |
---|---|---|
committer | BonfaceKilz | 2024-04-30 12:18:58 +0300 |
commit | 4d0326e998136bc330171bf760bc1e8a0a6cccf4 (patch) | |
tree | 67c67c84d91818ea687eacfc04ef1ddaf1dfc8c6 /gn3/api | |
parent | e4cc7ffce07f8c33f42e2ec0257277897217c98b (diff) | |
download | genenetwork3-4d0326e998136bc330171bf760bc1e8a0a6cccf4.tar.gz |
Add an endpoint to query a dataset's git history from it's id.
* gn3/api/metadata.py: Import get_history.
(view_history): New endpoint.
* gn3/db/datasets.py (get_history): New function.
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn3/api')
-rw-r--r-- | gn3/api/metadata.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/gn3/api/metadata.py b/gn3/api/metadata.py index fe7e903..a6a88fc 100644 --- a/gn3/api/metadata.py +++ b/gn3/api/metadata.py @@ -7,7 +7,8 @@ from flask import request from flask import current_app from gn3.db.datasets import (retrieve_metadata, - save_dataset_metadata) + save_metadata, + get_history) from gn3.db.rdf import RDF_PREFIXES from gn3.db.rdf import (query_frame_and_compact, query_and_compact, @@ -263,6 +264,26 @@ CONSTRUCT { ) +@metadata.route("/datasets/<id_>/history") +def view_history(id_): + history = get_history( + git_dir=Path(current_app.config.get("DATA_DIR"), + "gn-docs"), + name=id_, + ).either( + lambda error: { + "error": "Unable to fetch history", + "error_description": error, + }, + lambda history: { + "id": id_, + "history": history, + }) + if history.get("error"): + raise Exception(history.get("error_description")) + return history + + @metadata.route("/datasets/search/<term>", methods=["GET"]) def search_datasets(term): """Search datasets""" |