-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
plots2/app/controllers/tag_controller.rb
Lines 398 to 405 in 77188ba
def suggested | |
if !params[:id].empty? && params[:id].size > 2 | |
@suggestions = SearchService.new.search_tags(params[:id]) | |
render json: @suggestions.collect { |tag| tag.name }.uniq | |
else | |
render json: [] | |
end | |
end |
So when typing water
this endpoint returns:
[
"water",
"water-samples",
"waterkeepers",
"water-sampling",
"wateristic",
"wateristics",
"water-monitoring-network",
"water-monitoring",
"water-monitor",
"water-sensing"
]
My guess from this code: https://github.com/bassjobsen/Bootstrap-3-Typeahead/blob/fc2d5dce4a5406d9b924224e395d5647918707c7/bootstrap3-typeahead.js#L335-L352
...is that if an item has an attribute "category" then they will be sorted by that category.
But above they are just strings. We should switch to the JSON type shown here: https://github.com/bassjobsen/Bootstrap-3-Typeahead#using-json-objects-instead-of-simple-strings
So we will need to modify def suggested
above - and will have to be careful that doesn't break anything else (some other systems may depend on it returning a string -- https://github.com/publiclab/plots2/search?q=suggested shows a few!)
So as not to break anything else, maybe we should use a params flag like params[:json]
and the request should be like: https://publiclab.org/tag/suggested/water?json=true
?