mirror of
https://github.com/searxng/searxng.git
synced 2025-08-30 07:04:53 +02:00
Remove changeQuery in favor of an immutable FullQuery
Also includes the following: - Introduce typing in RawTextQuery - Remove an outdated description based on the change - Refactor setting the autocomplete_location, its more clear to set the variable in the construct instead of within the method - Update unit tests to reflect updated functionality
This commit is contained in:
parent
050451347b
commit
476a3811d4
4 changed files with 33 additions and 28 deletions
|
@ -753,14 +753,14 @@ def search():
|
|||
# suggestions: use RawTextQuery to get the suggestion URLs with the same bang
|
||||
suggestion_urls = list(
|
||||
map(
|
||||
lambda suggestion: {'url': raw_text_query.changeQuery(suggestion).getFullQuery(), 'title': suggestion},
|
||||
lambda suggestion: {'url': raw_text_query.getFullQuery(suggestion), 'title': suggestion},
|
||||
result_container.suggestions,
|
||||
)
|
||||
)
|
||||
|
||||
correction_urls = list(
|
||||
map(
|
||||
lambda correction: {'url': raw_text_query.changeQuery(correction).getFullQuery(), 'title': correction},
|
||||
lambda correction: {'url': raw_text_query.getFullQuery(correction), 'title': correction},
|
||||
result_container.corrections,
|
||||
)
|
||||
)
|
||||
|
@ -851,10 +851,8 @@ def autocompleter():
|
|||
backend_name = request.preferences.get_value('autocomplete')
|
||||
|
||||
for result in search_autocomplete(backend_name, sug_prefix, sxng_locale):
|
||||
# attention: this loop will change raw_text_query object and this is
|
||||
# the reason why the sug_prefix was stored before (see above)
|
||||
if result != sug_prefix:
|
||||
results.append(raw_text_query.changeQuery(result).getFullQuery())
|
||||
results.append(raw_text_query.getNewFullQuery(result))
|
||||
|
||||
if len(raw_text_query.autocomplete_list) > 0:
|
||||
for autocomplete_text in raw_text_query.autocomplete_list:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue