clientperf 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/clientperf.gemspec +2 -2
- data/lib/clientperf.rb +1 -1
- data/lib/clientperf_data_builder.rb +8 -3
- data/lib/clientperf_result.rb +2 -2
- data/lib/clientperf_uri.rb +2 -2
- metadata +1 -1
data/clientperf.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
|
2
|
-
# Gem::Specification for Clientperf-0.1.
|
2
|
+
# Gem::Specification for Clientperf-0.1.4
|
3
3
|
# Originally generated by Echoe
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = %q{clientperf}
|
7
|
-
s.version = "0.1.
|
7
|
+
s.version = "0.1.4"
|
8
8
|
|
9
9
|
s.specification_version = 2 if s.respond_to? :specification_version=
|
10
10
|
|
data/lib/clientperf.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
module ClientperfDataBuilder
|
2
2
|
def build_data_for_chart(results, start_time, periods, period_increment)
|
3
3
|
max = 0
|
4
|
-
if period_increment == :days && ActiveRecord::Base.default_timezone == :utc
|
5
|
-
start_time = start_time.to_datetime.change(:offset => 0).to_time
|
6
|
-
end
|
7
4
|
padded_results = (0..periods).map do |delta|
|
8
5
|
time_period = start_time + delta.send(period_increment)
|
9
6
|
data = get_data_or_pad(time_period, results)
|
@@ -13,6 +10,14 @@ module ClientperfDataBuilder
|
|
13
10
|
[padded_results, max]
|
14
11
|
end
|
15
12
|
|
13
|
+
def day_start_time
|
14
|
+
((ActiveRecord::Base.default_timezone == :utc ? Time.now.utc : Time.now) + 1.hour - 1.day).change(:min => 0)
|
15
|
+
end
|
16
|
+
|
17
|
+
def month_start_time
|
18
|
+
((ActiveRecord::Base.default_timezone == :utc ? Time.now.utc : Time.now) + 1.day - 30.days).change(:hour => 0)
|
19
|
+
end
|
20
|
+
|
16
21
|
private
|
17
22
|
|
18
23
|
def get_data_or_pad(point, results)
|
data/lib/clientperf_result.rb
CHANGED
@@ -6,7 +6,7 @@ class ClientperfResult < ActiveRecord::Base
|
|
6
6
|
include ClientperfDataBuilder
|
7
7
|
|
8
8
|
def last_24_hours
|
9
|
-
start_time =
|
9
|
+
start_time = day_start_time
|
10
10
|
results = average(:milliseconds, :conditions => ['created_at > ?', start_time],
|
11
11
|
:group => "date_format(created_at,'%Y-%m-%d %H')")
|
12
12
|
|
@@ -14,7 +14,7 @@ class ClientperfResult < ActiveRecord::Base
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def last_30_days
|
17
|
-
start_time =
|
17
|
+
start_time = month_start_time
|
18
18
|
results = average(:milliseconds, :conditions => ['created_at > ?', start_time],
|
19
19
|
:group => "date_format(created_at,'%Y-%m-%d')")
|
20
20
|
|
data/lib/clientperf_uri.rb
CHANGED
@@ -3,7 +3,7 @@ class ClientperfUri < ActiveRecord::Base
|
|
3
3
|
has_many :clientperf_results, :dependent => :delete_all
|
4
4
|
|
5
5
|
def last_24_hours
|
6
|
-
start_time =
|
6
|
+
start_time = day_start_time
|
7
7
|
results = clientperf_results.average(:milliseconds, :conditions => ['created_at > ?', start_time],
|
8
8
|
:group => "date_format(created_at,'%Y-%m-%d %H')")
|
9
9
|
|
@@ -11,7 +11,7 @@ class ClientperfUri < ActiveRecord::Base
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def last_30_days
|
14
|
-
start_time =
|
14
|
+
start_time = month_start_time
|
15
15
|
results = clientperf_results.average(:milliseconds, :conditions => ['created_at > ?', start_time],
|
16
16
|
:group => "date_format(created_at,'%Y-%m-%d')")
|
17
17
|
|