From a5544ab95e0acfa30ea6eb933d9d842b2027c83d Mon Sep 17 00:00:00 2001
From: asciimoo
Date: Sun, 5 Jan 2014 23:13:53 +0100
Subject: [PATCH 1/2] [enh] score per result stat added
---
searx/engines/__init__.py | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py
index 1ca11ff90..e011737cf 100644
--- a/searx/engines/__init__.py
+++ b/searx/engines/__init__.py
@@ -226,12 +226,14 @@ def search(query, request, selected_engines):
return results, suggestions
def get_engines_stats():
+ # TODO refactor
pageloads = []
results = []
scores = []
errors = []
+ scores_per_result = []
- max_pageload = max_results = max_score = max_errors = 0
+ max_pageload = max_results = max_score = max_errors = max_score_per_result = 0
for engine in engines.values():
if engine.stats['search_count'] == 0:
continue
@@ -239,16 +241,19 @@ def get_engines_stats():
load_times = engine.stats['page_load_time']/float(engine.stats['search_count'])
if results_num:
score = engine.stats['score_count'] / float(engine.stats['search_count'])
+ score_per_result = score / results_num
else:
- score = 0
+ score = score_per_result = 0.0
max_results = max(results_num, max_results)
max_pageload = max(load_times, max_pageload)
max_score = max(score, max_score)
+ max_score_per_result = max(score_per_result, max_score_per_result)
max_errors = max(max_errors, engine.stats['errors'])
pageloads.append({'avg': load_times, 'name': engine.name})
results.append({'avg': results_num, 'name': engine.name})
scores.append({'avg': score, 'name': engine.name})
errors.append({'avg': engine.stats['errors'], 'name': engine.name})
+ scores_per_result.append({'avg': score_per_result, 'name': engine.name})
for engine in pageloads:
engine['percentage'] = int(engine['avg']/max_pageload*100)
@@ -259,6 +264,9 @@ def get_engines_stats():
for engine in scores:
engine['percentage'] = int(engine['avg']/max_score*100)
+ for engine in scores_per_result:
+ engine['percentage'] = int(engine['avg']/max_score_per_result*100)
+
for engine in errors:
if max_errors:
engine['percentage'] = int(float(engine['avg'])/max_errors*100)
@@ -269,5 +277,6 @@ def get_engines_stats():
return [('Page loads (sec)', sorted(pageloads, key=itemgetter('avg')))
,('Number of results', sorted(results, key=itemgetter('avg'), reverse=True))
,('Scores', sorted(scores, key=itemgetter('avg'), reverse=True))
+ ,('Scores per result', sorted(scores_per_result, key=itemgetter('avg'), reverse=True))
,('Errors', sorted(errors, key=itemgetter('avg'), reverse=True))
]
From 23b327c6ae47c4b9bc9f00f95b19201b37d237d6 Mon Sep 17 00:00:00 2001
From: asciimoo
Date: Mon, 6 Jan 2014 00:19:47 +0100
Subject: [PATCH 2/2] [fix] html5 compatibility
---
searx/templates/about.html | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/searx/templates/about.html b/searx/templates/about.html
index 14a0080f9..977422c5d 100644
--- a/searx/templates/about.html
+++ b/searx/templates/about.html
@@ -39,11 +39,11 @@
Install searx as a search engine on any version of Firefox! (javascript required)
Developer FAQ
New engines?
-
+Don't forget to restart searx after config edit!
-
+
+Don't forget to restart searx after config edit!
WSGI support?
Okhin wrote a great and detailed article about the setup.
How to debug engines?