mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 11:42:53 +08:00
If a search for a translation is exactly the value, prioritize it
This commit is contained in:
parent
de88be2fbc
commit
b0b85725ad
|
@ -20,10 +20,17 @@ class Admin::SiteTextsController < Admin::AdminController
|
|||
translations.each do |k, v|
|
||||
results << {id: k, value: v}
|
||||
end
|
||||
|
||||
results.sort! do |x, y|
|
||||
if x[:value].casecmp(params[:q]) == 0
|
||||
-1
|
||||
elsif y[:value].casecmp(params[:q]) == 0
|
||||
1
|
||||
else
|
||||
(x[:id].size + x[:value].size) <=> (y[:id].size + y[:value].size)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
render_serialized(results[0..50], SiteTextSerializer, root: 'site_texts', rest_serializer: true, extras: extras)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user