diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2020-07-24 12:43:25 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2020-07-30 18:28:03 -0700 |
commit | 86c150edadad347df31393742c2de091ff21da83 (patch) | |
tree | bc70b17412d0f0a887f6fd5b63a9ded7af35e6b3 | |
parent | 216a062f48445f3d90e59485089211ca423affe8 (diff) | |
download | fatcat-86c150edadad347df31393742c2de091ff21da83.tar.gz fatcat-86c150edadad347df31393742c2de091ff21da83.zip |
move container _stats enrichment to routes
These were being added to many views which didn't need them (eg,
metadata, editing views)
-rw-r--r-- | python/fatcat_web/entity_helpers.py | 9 | ||||
-rw-r--r-- | python/fatcat_web/routes.py | 4 |
2 files changed, 4 insertions, 9 deletions
diff --git a/python/fatcat_web/entity_helpers.py b/python/fatcat_web/entity_helpers.py index 695ac426..c9a57290 100644 --- a/python/fatcat_web/entity_helpers.py +++ b/python/fatcat_web/entity_helpers.py @@ -2,8 +2,7 @@ from flask import abort from fatcat_openapi_client.rest import ApiException, ApiValueError from fatcat_tools.transforms import * -from fatcat_web import app, api -from fatcat_web.search import get_elastic_container_stats +from fatcat_web import api from fatcat_web.hacks import strip_extlink_xml, wayback_suffix def enrich_container_entity(entity): @@ -11,12 +10,6 @@ def enrich_container_entity(entity): return entity if entity.state == "active": entity._es = container_to_elasticsearch(entity, force_bool=False) - entity._stats = None - try: - entity._stats = get_elastic_container_stats(entity.ident, issnl=entity.issnl) - except ValueError as e: - app.log.error(e) - pass return entity def enrich_creator_entity(entity): diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py index 0fb0852c..203d1621 100644 --- a/python/fatcat_web/routes.py +++ b/python/fatcat_web/routes.py @@ -14,7 +14,7 @@ from fatcat_tools.normal import * from fatcat_web import app, api, auth_api, priv_api, mwoauth, Config from fatcat_web.auth import handle_token_login, handle_logout, load_user, handle_ia_xauth, handle_wmoauth from fatcat_web.cors import crossdomain -from fatcat_web.search import ReleaseQuery, GenericQuery, do_release_search, do_container_search, get_elastic_entity_stats, get_elastic_container_stats, get_elastic_container_histogram_legacy, get_elastic_container_preservation_by_year, get_elastic_container_preservation_by_volume, get_elastic_container_preservation_by_type, get_elastic_container_random_releases, FatcatSearchError +from fatcat_web.search import * from fatcat_web.entity_helpers import * from fatcat_web.graphics import * from fatcat_web.kafka import * @@ -201,8 +201,10 @@ def generic_entity_view(entity_type, ident, view_template): entity._metadata = metadata if view_template == "container_view.html": + entity._stats = get_elastic_container_stats(entity.ident, issnl=entity.issnl) entity._random_releases = get_elastic_container_random_releases(entity.ident) if view_template == "container_view_coverage.html": + entity._stats = get_elastic_container_stats(entity.ident, issnl=entity.issnl) entity._type_preservation = get_elastic_container_preservation_by_type(ident) return render_template(view_template, entity_type=entity_type, entity=entity, editgroup_id=None) |