Files
danbooru/app/controllers/saved_searches_controller.rb
evazion 378559ff47 autocomplete: make number of results configurable (partly).
Add `Danbooru.Autocomplete.MAX_RESULTS` param that controls the number
of results returned by autocomplete.

This does not work with tag autocomplete for Builders. Builder
autocomplete still needs to be refactored and unified with Member
autocomplete.

Also fix a bug in the /saved_searches/labels endpoint where the limit
param wasn't respected.
2019-11-13 01:47:41 -06:00

45 lines
1.0 KiB
Ruby

class SavedSearchesController < ApplicationController
respond_to :html, :xml, :json, :js
def index
@saved_searches = saved_searches.paginated_search(params, count_pages: true)
respond_with(@saved_searches)
end
def labels
@labels = SavedSearch.search_labels(CurrentUser.id, params[:search]).take(params[:limit].to_i || 10)
respond_with(@labels)
end
def create
@saved_search = saved_searches.create(saved_search_params)
respond_with(@saved_search)
end
def destroy
@saved_search = saved_searches.find(params[:id])
@saved_search.destroy
respond_with(@saved_search)
end
def edit
@saved_search = saved_searches.find(params[:id])
end
def update
@saved_search = saved_searches.find(params[:id])
@saved_search.update(saved_search_params)
respond_with(@saved_search, :location => saved_searches_path)
end
private
def saved_searches
CurrentUser.user.saved_searches
end
def saved_search_params
params.fetch(:saved_search, {}).permit(%i[query label_string disable_labels])
end
end