summaryrefslogtreecommitdiff
path: root/searx/webapp.py
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2022-01-17 08:06:31 +0100
committerMartin Fischer <martin@push-f.com>2022-01-17 11:42:48 +0100
commitfdf562bc32028cc0a2d3da1bad02a84da1e6a1d6 (patch)
treeb6095e5721ee680463703eb6a043d94fdcbd0853 /searx/webapp.py
parent1ed618222f17e205b684f6ef63cdaa470beb0dcb (diff)
[typing] add results.Timing
Diffstat (limited to 'searx/webapp.py')
-rwxr-xr-xsearx/webapp.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/searx/webapp.py b/searx/webapp.py
index 905f53d1..fc851d44 100755
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -56,6 +56,7 @@ from searx import (
searx_debug,
)
from searx.data import ENGINE_DESCRIPTIONS
+from searx.results import Timing
from searx.settings_defaults import OUTPUT_FORMATS
from searx.settings_loader import get_default_settings_path
from searx.exceptions import SearxParameterException
@@ -234,7 +235,7 @@ class ExtendedRequest(flask.Request):
form: Dict[str, str]
start_time: float
render_time: float
- timings: List[dict]
+ timings: List[Timing]
request = typing.cast(ExtendedRequest, flask.request)
@@ -585,15 +586,14 @@ def post_request(response):
'render;dur=' + str(round(request.render_time * 1000, 3)),
]
if len(request.timings) > 0:
- timings = sorted(request.timings, key=lambda v: v['total'])
+ timings = sorted(request.timings, key=lambda t: t.total)
timings_total = [
- 'total_' + str(i) + '_' + v['engine'] + ';dur=' + str(round(v['total'] * 1000, 3))
- for i, v in enumerate(timings)
+ 'total_' + str(i) + '_' + t.engine + ';dur=' + str(round(t.total * 1000, 3)) for i, t in enumerate(timings)
]
timings_load = [
- 'load_' + str(i) + '_' + v['engine'] + ';dur=' + str(round(v['load'] * 1000, 3))
- for i, v in enumerate(timings)
- if v.get('load')
+ 'load_' + str(i) + '_' + t.engine + ';dur=' + str(round(t.load * 1000, 3))
+ for i, t in enumerate(timings)
+ if t.load
]
timings_all = timings_all + timings_total + timings_load
response.headers.add('Server-Timing', ', '.join(timings_all))