Class: AwesomeExplain::PlanNode

Inherits:
Object
  • Object
show all
Defined in:
app/models/awesome_explain/plan_node.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



3
4
5
# File 'app/models/awesome_explain/plan_node.rb', line 3

def children
  @children
end

#documents_examinedObject

Returns the value of attribute documents_examined.



3
4
5
# File 'app/models/awesome_explain/plan_node.rb', line 3

def documents_examined
  @documents_examined
end

#documents_returnedObject

Returns the value of attribute documents_returned.



3
4
5
# File 'app/models/awesome_explain/plan_node.rb', line 3

def documents_returned
  @documents_returned
end

#durationObject

Returns the value of attribute duration.



3
4
5
# File 'app/models/awesome_explain/plan_node.rb', line 3

def duration
  @duration
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'app/models/awesome_explain/plan_node.rb', line 3

def id
  @id
end

#index_nameObject

Returns the value of attribute index_name.



3
4
5
# File 'app/models/awesome_explain/plan_node.rb', line 3

def index_name
  @index_name
end

#keys_examinedObject

Returns the value of attribute keys_examined.



3
4
5
# File 'app/models/awesome_explain/plan_node.rb', line 3

def keys_examined
  @keys_examined
end

#labelObject

Returns the value of attribute label.



3
4
5
# File 'app/models/awesome_explain/plan_node.rb', line 3

def label
  @label
end

#n_returnedObject

Returns the value of attribute n_returned.



3
4
5
# File 'app/models/awesome_explain/plan_node.rb', line 3

def n_returned
  @n_returned
end

#parentObject

Returns the value of attribute parent.



3
4
5
# File 'app/models/awesome_explain/plan_node.rb', line 3

def parent
  @parent
end

#treevizObject

Returns the value of attribute treeviz.



3
4
5
# File 'app/models/awesome_explain/plan_node.rb', line 3

def treeviz
  @treeviz
end

Class Method Details

.build(data, parent = nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/awesome_explain/plan_node.rb', line 15

def self.build(data, parent = nil)
  instance = PlanNode.new
  instance.label = data.dig(:stage)
  instance.documents_returned = data.dig(:docsReturned)
  instance.n_returned = data.dig(:nReturned)
  instance.documents_examined = data.dig(:docsExamined)
  instance.keys_examined = data.dig(:keysExamined)
  instance.duration = data.dig(:executionTimeMillisEstimate)
  instance.index_name = data.dig(:indexName)
  instance.parent = parent
  instance.children = []
  instance
end

Instance Method Details

#collscan?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'app/models/awesome_explain/plan_node.rb', line 29

def collscan?
  label.downcase == 'collscan'
end

#meta_dataObject



41
42
43
44
45
46
47
48
49
50
# File 'app/models/awesome_explain/plan_node.rb', line 41

def 
  data = []
  data << "<strong>Docs Returned:</strong> #{documents_returned}" if documents_returned.present?
  data << "<strong>N Returned:</strong> #{n_returned}" if n_returned.present?
  data << "<strong>Docs Examined:</strong> #{documents_examined}" if documents_examined.present?
  data << "<strong>Keys Examined</strong> #{keys_examined}" if keys_examined.present?
  data << "<strong>Duration</strong> #{duration}" if duration.present?
  data << "<strong>Index</strong> #{index_name}" if index_name.present?
  data
end

#meta_data_strObject



37
38
39
# File 'app/models/awesome_explain/plan_node.rb', line 37

def 
  .join('<hr />')
end