From e65edb141d4c5ac7811a77874390492be1872a9b Mon Sep 17 00:00:00 2001 From: GenericMale Date: Thu, 22 Aug 2024 19:14:24 +0200 Subject: [PATCH] [feat] results: show response times --- .../static/themes/simple/src/less/style.less | 14 ++++++ .../simple/elements/engines_msg.html | 45 +++++++++++-------- searx/templates/simple/results.html | 6 +-- searx/webapp.py | 9 +++- 4 files changed, 50 insertions(+), 24 deletions(-) diff --git a/searx/static/themes/simple/src/less/style.less b/searx/static/themes/simple/src/less/style.less index b7cd475f7..b7105e639 100644 --- a/searx/static/themes/simple/src/less/style.less +++ b/searx/static/themes/simple/src/less/style.less @@ -748,6 +748,20 @@ summary.title { } } +#engines_msg { + .engine-name { + width: 10rem; + } + + .response-error { + color: var(--color-error); + } + + .bar-chart-value { + width: auto; + } +} + #search_url { div.selectable_url { pre { diff --git a/searx/templates/simple/elements/engines_msg.html b/searx/templates/simple/elements/engines_msg.html index db1cefaaf..8ce784582 100644 --- a/searx/templates/simple/elements/engines_msg.html +++ b/searx/templates/simple/elements/engines_msg.html @@ -1,27 +1,34 @@
{% if not results and not answers %}
diff --git a/searx/templates/simple/results.html b/searx/templates/simple/results.html index 52b474c77..05a21674f 100644 --- a/searx/templates/simple/results.html +++ b/searx/templates/simple/results.html @@ -57,14 +57,12 @@ {%- include 'simple/elements/suggestions.html' -%} {%- endif -%} + {%- include 'simple/elements/engines_msg.html' -%} + {%- if method == 'POST' -%} {%- include 'simple/elements/search_url.html' -%} {%- endif -%} - {%- if unresponsive_engines -%} - {%- include 'simple/elements/engines_msg.html' -%} - {%- endif -%} - {%- if search_formats -%} {%- include 'simple/elements/apis.html' -%} {%- endif -%} diff --git a/searx/webapp.py b/searx/webapp.py index 4ecc9559e..dd79defcb 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -761,6 +761,11 @@ def search(): ) ) + # engine_timings: get engine response times sorted from slowest to fastest + engine_timings = sorted(result_container.get_timings(), reverse=True, key=lambda e: e.total) + max_response_time = engine_timings[0].total if engine_timings else None + engine_timings_pairs = [(timing.engine, timing.total) for timing in engine_timings] + # search_query.lang contains the user choice (all, auto, en, ...) # when the user choice is "auto", search.search_query.lang contains the detected language # otherwise it is equals to search_query.lang @@ -789,7 +794,9 @@ def search(): settings['search']['languages'], fallback=request.preferences.get_value("language") ), - timeout_limit = request.form.get('timeout_limit', None) + timeout_limit = request.form.get('timeout_limit', None), + timings = engine_timings_pairs, + max_response_time = max_response_time # fmt: on )