Class: RailsPulse::Charts::OperationsChart
- Inherits:
-
Object
- Object
- RailsPulse::Charts::OperationsChart
- Defined in:
- app/models/rails_pulse/charts/operations_chart.rb
Defined Under Namespace
Classes: OperationBar
Constant Summary collapse
- LANE_DISPLAY =
{ "controller" => { label: "Action", order: 0 }, "template" => { label: "View", order: 1 }, "layout" => { label: "View", order: 1 }, "partial" => { label: "Partial", order: 2 }, "collection" => { label: "Partial", order: 2 }, "sql" => { label: "Database", order: 3 }, "cache_read" => { label: "Cache", order: 4 }, "cache_write" => { label: "Cache", order: 4 }, "http" => { label: "External", order: 5 }, "job" => { label: "External", order: 5 }, "mailer" => { label: "External", order: 5 }, "storage" => { label: "External", order: 5 } }.freeze
- HORIZONTAL_OFFSET_PX =
20
Instance Attribute Summary collapse
-
#bars ⇒ Object
readonly
Returns the value of attribute bars.
-
#lane_labels ⇒ Object
readonly
Returns the value of attribute lane_labels.
-
#max_depth ⇒ Object
readonly
Returns the value of attribute max_depth.
-
#max_end ⇒ Object
readonly
Returns the value of attribute max_end.
-
#min_start ⇒ Object
readonly
Returns the value of attribute min_start.
-
#total_duration ⇒ Object
readonly
Returns the value of attribute total_duration.
Instance Method Summary collapse
-
#initialize(operations) ⇒ OperationsChart
constructor
A new instance of OperationsChart.
Constructor Details
#initialize(operations) ⇒ OperationsChart
Returns a new instance of OperationsChart.
25 26 27 28 29 30 31 32 33 |
# File 'app/models/rails_pulse/charts/operations_chart.rb', line 25 def initialize(operations) @operations = operations.to_a @min_start = @operations.map(&:start_time).min || 0 @max_end = @operations.map { |op| op.start_time + op.duration }.max || 1 @total_duration = (@max_end - @min_start).nonzero? || 1 @bars = @max_depth = @bars.map(&:depth).max || 0 @lane_labels = build_lane_labels end |
Instance Attribute Details
#bars ⇒ Object (readonly)
Returns the value of attribute bars.
21 22 23 |
# File 'app/models/rails_pulse/charts/operations_chart.rb', line 21 def @bars end |
#lane_labels ⇒ Object (readonly)
Returns the value of attribute lane_labels.
21 22 23 |
# File 'app/models/rails_pulse/charts/operations_chart.rb', line 21 def lane_labels @lane_labels end |
#max_depth ⇒ Object (readonly)
Returns the value of attribute max_depth.
21 22 23 |
# File 'app/models/rails_pulse/charts/operations_chart.rb', line 21 def max_depth @max_depth end |
#max_end ⇒ Object (readonly)
Returns the value of attribute max_end.
21 22 23 |
# File 'app/models/rails_pulse/charts/operations_chart.rb', line 21 def max_end @max_end end |
#min_start ⇒ Object (readonly)
Returns the value of attribute min_start.
21 22 23 |
# File 'app/models/rails_pulse/charts/operations_chart.rb', line 21 def min_start @min_start end |
#total_duration ⇒ Object (readonly)
Returns the value of attribute total_duration.
21 22 23 |
# File 'app/models/rails_pulse/charts/operations_chart.rb', line 21 def total_duration @total_duration end |