class RelationshipAnalyzesController < ApplicationController
def show
@search = @analyze.search_results(params)
@results = @search.results.map { |result| AnalyzeResultPresenter.new(result) }
end
end
class AnalyzeResult < ActiveRecord::Base
searchable do
#...
end
def search_results
RelationshipAnalyzeResult.solr_search do
#...
end
end
end
class AnalyzeResultPresenter
def initialize(relationship_analyze_result)
tw_computing = analyze_result.analyze.brand.twitter_id.present? ? 'En cours' : '-'
fb_computing = analyze_result.analyze.brand.facebook_id.present? ? 'En cours' : '-'
#...
@celebrity = analyze_result.celebrity
end
end
LOGS :
- 106 lines
- 105
SELECT
requests Complete in 1106ms
def search_results
RelationshipAnalyzeResult.solr_search(include: %i(celebrity brand)) do
#...
end
end
LOGS :
- 19 lines
- 18
SELECT
requests Complete in 553ms