diff options
author | Thomas Pointhuber <thomas.pointhuber@gmx.at> | 2014-10-01 19:16:34 +0200 |
---|---|---|
committer | Thomas Pointhuber <thomas.pointhuber@gmx.at> | 2014-10-01 19:16:34 +0200 |
commit | fdad5f7cada577da67c340f83ee77e2383f12979 (patch) | |
tree | b545582a7800be860c888fab450e879809a4b85e /searx | |
parent | 5dc3eb3399366b3e30caac1cbd271018da4d7d45 (diff) | |
download | searxng-fdad5f7cada577da67c340f83ee77e2383f12979.tar.gz searxng-fdad5f7cada577da67c340f83ee77e2383f12979.zip |
fix float division by zero bug in score calculation
Diffstat (limited to 'searx')
-rw-r--r-- | searx/engines/__init__.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py index 82c9407a2..e63dd7189 100644 --- a/searx/engines/__init__.py +++ b/searx/engines/__init__.py @@ -142,16 +142,28 @@ def get_engines_stats(): }) for engine in pageloads: - engine['percentage'] = int(engine['avg'] / max_pageload * 100) + if max_pageload: + engine['percentage'] = int(engine['avg'] / max_pageload * 100) + else: + engine['percentage'] = 0 for engine in results: - engine['percentage'] = int(engine['avg'] / max_results * 100) + if max_results: + engine['percentage'] = int(engine['avg'] / max_results * 100) + else: + engine['percentage'] = 0 for engine in scores: - engine['percentage'] = int(engine['avg'] / max_score * 100) + if max_score: + engine['percentage'] = int(engine['avg'] / max_score * 100) + else: + engine['percentage'] = 0 for engine in scores_per_result: - engine['percentage'] = int(engine['avg'] / max_score_per_result * 100) + if max_score_per_result: + engine['percentage'] = int(engine['avg'] / max_score_per_result * 100) + else: + engine['percentage'] = 0 for engine in errors: if max_errors: |