aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/routes.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2022-02-03 21:09:44 -0800
committerBryan Newbold <bnewbold@robocracy.org>2022-02-03 21:09:47 -0800
commitd9d9c32528c168114c4b1a6afeedf21674322f69 (patch)
tree54ca03b7dccb7d59a3cfb1dce9afc56064288e3e /python/fatcat_web/routes.py
parent3224fe8c43adcf3e2f6f5536e11a1ea793175b72 (diff)
downloadfatcat-d9d9c32528c168114c4b1a6afeedf21674322f69.tar.gz
fatcat-d9d9c32528c168114c4b1a6afeedf21674322f69.zip
small changes to preservation coverage search queries
- allow fetching of by-release-type preservation histograms as JSON - query flag to exclude 'stub' entity types - don't include 'stub' entities in container-by-year or container-by-volume charts (and JSON)
Diffstat (limited to 'python/fatcat_web/routes.py')
-rw-r--r--python/fatcat_web/routes.py29
1 files changed, 25 insertions, 4 deletions
diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py
index f180e339..a7fb34bd 100644
--- a/python/fatcat_web/routes.py
+++ b/python/fatcat_web/routes.py
@@ -1183,7 +1183,7 @@ def container_ident_preservation_by_year_json(ident: str) -> AnyResponse:
container = api.get_container(ident)
except ApiException as ae:
abort(ae.status)
- query = ReleaseQuery(container_id=container.ident)
+ query = ReleaseQuery(container_id=container.ident, exclude_stubs=True)
try:
histogram = get_elastic_preservation_by_year(query)
except Exception as ae:
@@ -1201,7 +1201,7 @@ def container_ident_preservation_by_year_svg(ident: str) -> AnyResponse:
container = api.get_container(ident)
except ApiException as ae:
abort(ae.status)
- query = ReleaseQuery(container_id=container.ident)
+ query = ReleaseQuery(container_id=container.ident, exclude_stubs=True)
try:
histogram = get_elastic_preservation_by_year(query)
except Exception as ae:
@@ -1223,8 +1223,9 @@ def container_ident_preservation_by_volume_json(ident: str) -> AnyResponse:
container = api.get_container(ident)
except ApiException as ae:
abort(ae.status)
+ query = ReleaseQuery(container_id=container.ident, exclude_stubs=True)
try:
- histogram = get_elastic_container_preservation_by_volume(container.ident)
+ histogram = get_elastic_container_preservation_by_volume(query)
except Exception as ae:
app.log.error(ae)
abort(503)
@@ -1241,8 +1242,9 @@ def container_ident_preservation_by_volume_svg(ident: str) -> AnyResponse:
container = api.get_container(ident)
except ApiException as ae:
abort(ae.status)
+ query = ReleaseQuery(container_id=container.ident, exclude_stubs=True)
try:
- histogram = get_elastic_container_preservation_by_volume(container.ident)
+ histogram = get_elastic_container_preservation_by_volume(query)
except Exception as ae:
app.log.error(ae)
abort(503)
@@ -1252,6 +1254,25 @@ def container_ident_preservation_by_volume_svg(ident: str) -> AnyResponse:
).render_response()
+@app.route(
+ "/container/<string(length=26):ident>/preservation_by_type.json",
+ methods=["GET", "OPTIONS"],
+)
+@crossdomain(origin="*", headers=["access-control-allow-origin", "Content-Type"])
+def container_ident_preservation_by_type_json(ident: str) -> AnyResponse:
+ try:
+ container = api.get_container(ident)
+ except ApiException as ae:
+ abort(ae.status)
+ query = ReleaseQuery(container_id=container.ident)
+ try:
+ histogram = get_elastic_preservation_by_type(query)
+ except Exception as ae:
+ app.log.error(ae)
+ abort(503)
+ return jsonify({"container_id": ident, "histogram": histogram})
+
+
@app.route("/release/<string(length=26):ident>.bib", methods=["GET"])
def release_bibtex(ident: str) -> AnyResponse:
try: