From 7010abf54fae6a04f4a0700651e64a1fe5b5b2c8 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 23 Jul 2020 16:10:40 -0700 Subject: re-order search params to satisfy pylint Moved all the request_cache=True param calls to just before ES request exectuation. The former ordering "just worked", but pylint didn't like it, and I suspose it was not as idiomatic as it should have been. --- python/fatcat_web/search.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'python/fatcat_web/search.py') diff --git a/python/fatcat_web/search.py b/python/fatcat_web/search.py index 1165a004..55caa9c5 100644 --- a/python/fatcat_web/search.py +++ b/python/fatcat_web/search.py @@ -246,9 +246,9 @@ def get_elastic_container_random_releases(ident, limit=5): ] ) search = search.sort('-in_web', '-release_date') - search = search.params(request_cache=True) search = search[:int(limit)] + search = search.params(request_cache=True) resp = wrap_es_execution(search) results = results_to_dict(resp) @@ -268,7 +268,6 @@ def get_elastic_entity_stats(): # release totals search = Search(using=app.es_client, index=app.config['ELASTICSEARCH_RELEASE_INDEX']) - search = search.params(request_cache=True) search.aggs.bucket( 'release_ref_count', 'sum', @@ -276,6 +275,7 @@ def get_elastic_entity_stats(): ) search = search[:0] # pylint: disable=unsubscriptable-object + search = search.params(request_cache=True) resp = wrap_es_execution(search) stats['release'] = { @@ -294,7 +294,6 @@ def get_elastic_entity_stats(): # "thesis", ], ) - search = search.params(request_cache=True) search.aggs.bucket( 'paper_like', 'filters', @@ -310,6 +309,7 @@ def get_elastic_entity_stats(): ) search = search[:0] + search = search.params(request_cache=True) resp = wrap_es_execution(search) buckets = resp.aggregations.paper_like.buckets stats['papers'] = { @@ -322,7 +322,6 @@ def get_elastic_entity_stats(): # container counts search = Search(using=app.es_client, index=app.config['ELASTICSEARCH_CONTAINER_INDEX']) - search = search.params(request_cache=True) search.aggs.bucket( 'release_ref_count', 'sum', @@ -330,6 +329,7 @@ def get_elastic_entity_stats(): ) search = search[:0] # pylint: disable=unsubscriptable-object + search = search.params(request_cache=True) resp = wrap_es_execution(search) stats['container'] = { "total": resp.hits.total, @@ -349,7 +349,6 @@ def get_elastic_container_stats(ident, issnl=None): """ search = Search(using=app.es_client, index=app.config['ELASTICSEARCH_RELEASE_INDEX']) - search = search.params(request_cache=True) search = search.query( 'term', container_id=ident, @@ -371,6 +370,7 @@ def get_elastic_container_stats(ident, issnl=None): ) search = search[:0] + search = search.params(request_cache=True) resp = wrap_es_execution(search) buckets = resp.aggregations.container_stats.buckets @@ -396,7 +396,6 @@ def get_elastic_container_histogram(ident): """ search = Search(using=app.es_client, index=app.config['ELASTICSEARCH_RELEASE_INDEX']) - search = search.params(request_cache='true') search = search.query( 'bool', must=[ @@ -431,6 +430,7 @@ def get_elastic_container_histogram(ident): ) search = search[:0] + search = search.params(request_cache='true') resp = wrap_es_execution(search) buckets = resp.aggregations.year_in_ia.buckets -- cgit v1.2.3