diff options
author | Alexandre Flament <alex@al-f.net> | 2021-05-19 11:25:32 +0200 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2021-05-22 15:17:18 +0200 |
commit | 3014463fedd5a4a1e4a7077578a8095e12390c9a (patch) | |
tree | 82fff9024e6b77d718bb7a487fef95fad0451634 /searx/metrics | |
parent | ec834935381e5cfb4ebc3820ed2f668d0fc7855d (diff) | |
download | searxng-3014463fedd5a4a1e4a7077578a8095e12390c9a.tar.gz searxng-3014463fedd5a4a1e4a7077578a8095e12390c9a.zip |
[fix] metrics: processing time = total time if there is no http time
It was previsouly None
Fix /stats
Diffstat (limited to 'searx/metrics')
-rw-r--r-- | searx/metrics/__init__.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/searx/metrics/__init__.py b/searx/metrics/__init__.py index c2dcfaae4..867daa068 100644 --- a/searx/metrics/__init__.py +++ b/searx/metrics/__init__.py @@ -157,7 +157,11 @@ def get_reliabilities(engline_name_list, checker_results): def round_or_none(number, digits): - return round(number, digits) if number else number + '''return None if number is None + return 0 if number is 0 + otherwise round number with "digits numbers. + ''' + return round(number, digits) if number is not None else number def get_engines_stats(engine_name_list): @@ -192,6 +196,8 @@ def get_engines_stats(engine_name_list): max_time_total = max(time_total or 0, max_time_total or 0) max_result_count = max(result_count or 0, max_result_count or 0) + time_total_is_number = time_total is not None + list_time.append({ 'name': engine_name, 'total': round_or_none(time_total, 1), @@ -200,9 +206,9 @@ def get_engines_stats(engine_name_list): 'http': round_or_none(time_http, 1), 'http_p80': round_or_none(time_http_p80, 1), 'http_p95': round_or_none(time_http_p95, 1), - 'processing': round(time_total - time_http, 1) if time_total else None, - 'processing_p80': round(time_total_p80 - time_http_p80, 1) if time_total else None, - 'processing_p95': round(time_total_p95 - time_http_p95, 1) if time_total else None, + 'processing': round(time_total - (time_http or 0), 1) if time_total_is_number else None, + 'processing_p80': round(time_total_p80 - (time_http_p80 or 0), 1) if time_total_is_number else None, + 'processing_p95': round(time_total_p95 - (time_http_p95 or 0), 1) if time_total_is_number else None, 'score': score, 'score_per_result': score_per_result, 'result_count': result_count, |