Module: ClientperfDataBuilder
- Included in:
- ClientperfResult, ClientperfUri
- Defined in:
- lib/clientperf_data_builder.rb
Instance Method Summary collapse
- #build_data_for_chart(results, start_time, periods, period_increment) ⇒ Object
- #day_start_time ⇒ Object
- #month_start_time ⇒ Object
Instance Method Details
#build_data_for_chart(results, start_time, periods, period_increment) ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/clientperf_data_builder.rb', line 2 def build_data_for_chart(results, start_time, periods, period_increment) max = 0 padded_results = (0..periods).map do |delta| time_period = start_time + delta.send(period_increment) data = get_data_or_pad(time_period, results) max = data if data && data > max [time_period, data] end [padded_results, max] end |
#day_start_time ⇒ Object
13 14 15 |
# File 'lib/clientperf_data_builder.rb', line 13 def day_start_time ((ActiveRecord::Base.default_timezone == :utc ? Time.now.utc : Time.now) + 1.hour - 1.day).change(:min => 0) end |
#month_start_time ⇒ Object
17 18 19 |
# File 'lib/clientperf_data_builder.rb', line 17 def month_start_time ((ActiveRecord::Base.default_timezone == :utc ? Time.now.utc : Time.now) + 1.day - 30.days).change(:hour => 0) end |