diff options
author | bnewbold <bnewbold@archive.org> | 2021-04-08 00:22:33 +0000 |
---|---|---|
committer | bnewbold <bnewbold@archive.org> | 2021-04-08 00:22:33 +0000 |
commit | 97280d0a20baa00aa1f8dbd3bec62142ad2ce900 (patch) | |
tree | 9320c75d5c19148aba7cd3a0ced0fc200988e6ba /python/fatcat_web | |
parent | 0b9fc884dad8e3147d10c273725157ba60f48069 (diff) | |
parent | 9f110393b90d5b9e95a39b4f83d3e864434dd189 (diff) | |
download | fatcat-97280d0a20baa00aa1f8dbd3bec62142ad2ce900.tar.gz fatcat-97280d0a20baa00aa1f8dbd3bec62142ad2ce900.zip |
Merge branch 'bnewbold-es-index-updates' into 'master'
fatcat elasticsearch schema updates
See merge request webgroup/fatcat!101
Diffstat (limited to 'python/fatcat_web')
-rw-r--r-- | python/fatcat_web/__init__.py | 6 | ||||
-rw-r--r-- | python/fatcat_web/search.py | 13 |
2 files changed, 14 insertions, 5 deletions
diff --git a/python/fatcat_web/__init__.py b/python/fatcat_web/__init__.py index 487de58a..07b4e083 100644 --- a/python/fatcat_web/__init__.py +++ b/python/fatcat_web/__init__.py @@ -1,4 +1,6 @@ +import sys + from flask import Flask from flask.logging import create_logger from flask_uuid import FlaskUUID @@ -56,10 +58,10 @@ def auth_api(token): return fatcat_openapi_client.DefaultApi(fatcat_openapi_client.ApiClient(conf)) if Config.FATCAT_API_AUTH_TOKEN: - print("Found and using privileged token (eg, for account signup)") + print("Found and using privileged token (eg, for account signup)", file=sys.stderr) priv_api = auth_api(Config.FATCAT_API_AUTH_TOKEN) else: - print("No privileged token found") + print("No privileged token found", file=sys.stderr) priv_api = None # TODO: refactor integration so this doesn't always need to be defined. If diff --git a/python/fatcat_web/search.py b/python/fatcat_web/search.py index 0cdb604a..2811b9a0 100644 --- a/python/fatcat_web/search.py +++ b/python/fatcat_web/search.py @@ -424,7 +424,7 @@ def get_elastic_search_coverage(query: ReleaseQuery) -> dict: return stats -def get_elastic_container_stats(ident, issnl=None): +def get_elastic_container_stats(ident, issnl=None, es_client=None, es_index=None, merge_shadows=None): """ Returns dict: ident @@ -435,7 +435,14 @@ def get_elastic_container_stats(ident, issnl=None): preserved """ - search = Search(using=app.es_client, index=app.config['ELASTICSEARCH_RELEASE_INDEX']) + if not es_client: + es_client = app.es_client + if not es_index: + es_index = app.config['ELASTICSEARCH_RELEASE_INDEX'] + if merge_shadows is None: + merge_shadows = app.config['FATCAT_MERGE_SHADOW_PRESERVATION'] + + search = Search(using=es_client, index=es_index) search = search.query( 'term', container_id=ident, @@ -479,7 +486,7 @@ def get_elastic_container_stats(ident, issnl=None): for k in ('bright', 'dark', 'shadows_only', 'none'): if not k in preservation_bucket: preservation_bucket[k] = 0 - if app.config['FATCAT_MERGE_SHADOW_PRESERVATION']: + if merge_shadows: preservation_bucket['none'] += preservation_bucket['shadows_only'] preservation_bucket['shadows_only'] = 0 release_type_bucket = agg_to_dict(resp.aggregations.release_type) |