/artists: avoid COUNT(*), avoid N+1 queries on artist urls.
* The /artists page issued a `SELECT count(*) FROM artists` because .paginate was missing search_count. * /artists.json had an N+1 problem on artist urls. This slowed down autocomplete.
This commit is contained in:
@@ -38,7 +38,7 @@ class ArtistsController < ApplicationController
|
||||
|
||||
def index
|
||||
search_params = params[:search].present? ? params[:search] : params
|
||||
@artists = Artist.search(search_params).order("id desc").paginate(params[:page], :limit => params[:limit])
|
||||
@artists = Artist.includes(:urls).search(search_params).order("id desc").paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
|
||||
respond_with(@artists) do |format|
|
||||
format.xml do
|
||||
render :xml => @artists.to_xml(:include => [:urls], :root => "artists")
|
||||
|
||||
Reference in New Issue
Block a user