Normally we skip doing page counts on index pages when there aren't any search filters. This is on the assumption that most index pages have more than 1000 pages (20,000 results), so it's not worth counting them exactly. This isn't always true, so here we turn on full counts on certain index pages known to be small.
45 lines
1.0 KiB
Ruby
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])
|
|
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
|