mirror of
https://github.com/searxng/searxng.git
synced 2024-11-19 19:00:10 +01:00
[fix] compute the order of results only once per search
This commit is contained in:
parent
485da54961
commit
5b5478bbd9
@ -380,7 +380,9 @@ def index():
|
|||||||
|
|
||||||
plugins.call('post_search', request, locals())
|
plugins.call('post_search', request, locals())
|
||||||
|
|
||||||
for result in search.result_container.get_ordered_results():
|
results = search.result_container.get_ordered_results()
|
||||||
|
|
||||||
|
for result in results:
|
||||||
|
|
||||||
plugins.call('on_result', request, locals())
|
plugins.call('on_result', request, locals())
|
||||||
if not search.paging and engines[result['engine']].paging:
|
if not search.paging and engines[result['engine']].paging:
|
||||||
@ -425,13 +427,13 @@ def index():
|
|||||||
if search.request_data.get('format') == 'json':
|
if search.request_data.get('format') == 'json':
|
||||||
return Response(json.dumps({'query': search.query,
|
return Response(json.dumps({'query': search.query,
|
||||||
'number_of_results': number_of_results,
|
'number_of_results': number_of_results,
|
||||||
'results': search.result_container.get_ordered_results()}),
|
'results': results}),
|
||||||
mimetype='application/json')
|
mimetype='application/json')
|
||||||
elif search.request_data.get('format') == 'csv':
|
elif search.request_data.get('format') == 'csv':
|
||||||
csv = UnicodeWriter(cStringIO.StringIO())
|
csv = UnicodeWriter(cStringIO.StringIO())
|
||||||
keys = ('title', 'url', 'content', 'host', 'engine', 'score')
|
keys = ('title', 'url', 'content', 'host', 'engine', 'score')
|
||||||
csv.writerow(keys)
|
csv.writerow(keys)
|
||||||
for row in search.result_container.get_ordered_results():
|
for row in results:
|
||||||
row['host'] = row['parsed_url'].netloc
|
row['host'] = row['parsed_url'].netloc
|
||||||
csv.writerow([row.get(key, '') for key in keys])
|
csv.writerow([row.get(key, '') for key in keys])
|
||||||
csv.stream.seek(0)
|
csv.stream.seek(0)
|
||||||
@ -442,7 +444,7 @@ def index():
|
|||||||
elif search.request_data.get('format') == 'rss':
|
elif search.request_data.get('format') == 'rss':
|
||||||
response_rss = render(
|
response_rss = render(
|
||||||
'opensearch_response_rss.xml',
|
'opensearch_response_rss.xml',
|
||||||
results=search.result_container.get_ordered_results(),
|
results=results,
|
||||||
q=search.request_data['q'],
|
q=search.request_data['q'],
|
||||||
number_of_results=number_of_results,
|
number_of_results=number_of_results,
|
||||||
base_url=get_base_url()
|
base_url=get_base_url()
|
||||||
@ -451,7 +453,7 @@ def index():
|
|||||||
|
|
||||||
return render(
|
return render(
|
||||||
'results.html',
|
'results.html',
|
||||||
results=search.result_container.get_ordered_results(),
|
results=results,
|
||||||
q=search.request_data['q'],
|
q=search.request_data['q'],
|
||||||
selected_categories=search.categories,
|
selected_categories=search.categories,
|
||||||
paging=search.paging,
|
paging=search.paging,
|
||||||
|
Loading…
Reference in New Issue
Block a user