Class: LogMagic::SearchkickExplainer::QueryExplainerSection

Inherits:
Object
  • Object
show all
Includes:
JSONUtils, TemplatingUtils
Defined in:
lib/log_magic/explainers/searchkick/query_explainer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from JSONUtils

#parse_json, #pretty_print_json, #query_hash

Methods included from TemplatingUtils

#enriche, #match_regex, #rendered_template, #template_dir, #template_path

Constructor Details

#initialize(query_json) ⇒ QueryExplainerSection

Returns a new instance of QueryExplainerSection.



6
7
8
9
# File 'lib/log_magic/explainers/searchkick/query_explainer.rb', line 6

def initialize(query_json)
  @query_json = pretty_print_json(query_json)
  enriche_query_json
end

Instance Attribute Details

#query_jsonObject (readonly)

Returns the value of attribute query_json.



4
5
6
# File 'lib/log_magic/explainers/searchkick/query_explainer.rb', line 4

def query_json
  @query_json
end

Instance Method Details

#enriche_query_jsonObject



31
32
33
34
35
36
37
# File 'lib/log_magic/explainers/searchkick/query_explainer.rb', line 31

def enriche_query_json
  explainer_section_classes.map do |explainer_section_class|
    explainer_section_class.new(query_json)
  end.select do |explainer_section|
    explainer_section.enriche
  end
end

#explainer_section_classesObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/log_magic/explainers/searchkick/query_explainer.rb', line 19

def explainer_section_classes
  [
    ::LogMagic::SearchkickExplainer::DisMaxExplainerSection,
    ::LogMagic::SearchkickExplainer::BoostExplainerSection,
    ::LogMagic::SearchkickExplainer::MatchExplainerSection,
    ::LogMagic::SearchkickExplainer::AnalyzerExplainerSection,
    ::LogMagic::SearchkickExplainer::FuzzyTranspositionsSection,
    ::LogMagic::SearchkickExplainer::MaxExpansionsSection,
    ::LogMagic::SearchkickExplainer::UnderscoreAllExplainerSection
  ]
end

#explanationObject



11
12
13
# File 'lib/log_magic/explainers/searchkick/query_explainer.rb', line 11

def explanation
  rendered_template
end

#template_nameObject



15
16
17
# File 'lib/log_magic/explainers/searchkick/query_explainer.rb', line 15

def template_name
  'query.haml'
end