appstats 0.18.0 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/db/migrations/20110321154125_add_appstats_results_query_duration_in_seconds.rb +11 -0
- data/db/schema.rb +3 -1
- data/lib/appstats.rb +1 -0
- data/lib/appstats/friendly_timer.rb +52 -0
- data/lib/appstats/query.rb +6 -1
- data/lib/appstats/result.rb +12 -2
- data/lib/appstats/version.rb +1 -1
- data/spec/entry_spec.rb +8 -8
- data/spec/friendly_timer_spec.rb +174 -0
- data/spec/logger_spec.rb +22 -22
- data/spec/query_spec.rb +669 -644
- data/spec/result_spec.rb +46 -1
- metadata +8 -4
data/spec/result_spec.rb
CHANGED
@@ -27,10 +27,12 @@ module Appstats
|
|
27
27
|
@result.db_host.should == nil
|
28
28
|
@result.is_latest.should == nil
|
29
29
|
@result.is_latest?.should == false
|
30
|
+
@result.query_duration_in_seconds.should == nil
|
31
|
+
@result.group_query_duration_in_seconds.should == nil
|
30
32
|
end
|
31
33
|
|
32
34
|
it "should set on constructor" do
|
33
|
-
result = Appstats::Result.new(:name => 'a', :result_type => 'b', :query => 'c', :query_to_sql => 'd', :count => 10, :action => 'e', :host => 'f', :contexts => 'g', :from_date => Time.parse("2010-01-02"), :to_date => Time.parse("2010-02-03"), :group_by => "a,b", :query_type => 'h', :db_username => 'i', :db_name => 'j', :db_host => 'k', :is_latest => true)
|
35
|
+
result = Appstats::Result.new(:name => 'a', :result_type => 'b', :query => 'c', :query_to_sql => 'd', :count => 10, :action => 'e', :host => 'f', :contexts => 'g', :from_date => Time.parse("2010-01-02"), :to_date => Time.parse("2010-02-03"), :group_by => "a,b", :query_type => 'h', :db_username => 'i', :db_name => 'j', :db_host => 'k', :is_latest => true, :query_duration_in_seconds => 1.2, :group_query_duration_in_seconds => 3.4)
|
34
36
|
result.name.should == 'a'
|
35
37
|
result.result_type.should == 'b'
|
36
38
|
result.query.should == 'c'
|
@@ -48,6 +50,8 @@ module Appstats
|
|
48
50
|
result.db_host.should == "k"
|
49
51
|
result.is_latest?.should == true
|
50
52
|
result.is_latest.should == true
|
53
|
+
result.query_duration_in_seconds = 1.2
|
54
|
+
result.group_query_duration_in_seconds = 3.4
|
51
55
|
end
|
52
56
|
|
53
57
|
end
|
@@ -60,6 +64,18 @@ module Appstats
|
|
60
64
|
(result == same_result).should == true
|
61
65
|
end
|
62
66
|
|
67
|
+
it "should ignore query_duration_in_seconds" do
|
68
|
+
result = Appstats::Result.new(:query_duration_in_seconds => 1.2)
|
69
|
+
result2 = Appstats::Result.new(:query_duration_in_seconds => 3.4)
|
70
|
+
result.should == result2
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should ignore group_query_duration_in_seconds" do
|
74
|
+
result = Appstats::Result.new(:group_query_duration_in_seconds => 1.2)
|
75
|
+
result2 = Appstats::Result.new(:group_query_duration_in_seconds => 3.4)
|
76
|
+
result.should == result2
|
77
|
+
end
|
78
|
+
|
63
79
|
it "should be not equal if diferent attributes" do
|
64
80
|
result = Appstats::Result.new(:name => 'a', :result_type => 'b', :query => 'c', :query_to_sql => 'd', :count => 10, :action => 'e', :host => 'f', :contexts => 'g', :from_date => Time.parse("2010-01-02"), :to_date => Time.parse("2010-02-03"), :group_by => "a,b", :query_type => 'h', :db_username => 'i', :db_name => 'j', :db_host => 'k')
|
65
81
|
|
@@ -78,6 +94,35 @@ module Appstats
|
|
78
94
|
|
79
95
|
end
|
80
96
|
|
97
|
+
describe "#query_duration_to_s" do
|
98
|
+
|
99
|
+
it "should be friendly" do
|
100
|
+
@result.query_duration_in_seconds = 10
|
101
|
+
@result.query_duration_to_s.should == "10 seconds"
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should support nil" do
|
105
|
+
@result.query_duration_in_seconds = nil
|
106
|
+
@result.query_duration_to_s.should == "N/A"
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#group_query_duration_to_s" do
|
112
|
+
|
113
|
+
it "should be friendly" do
|
114
|
+
@result.group_query_duration_in_seconds = 10
|
115
|
+
@result.group_query_duration_to_s.should == "10 seconds"
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should support nil" do
|
119
|
+
@result.group_query_duration_in_seconds = nil
|
120
|
+
@result.group_query_duration_to_s.should == "N/A"
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
|
81
126
|
describe "#host_to_s" do
|
82
127
|
|
83
128
|
it "should take host if set (but not db_host)" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appstats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 83
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 19
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.19.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andrew Forward
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-21 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -180,6 +180,7 @@ files:
|
|
180
180
|
- db/migrations/20110301230757_rename_appstats_results_query_as_sql_to_query_to_sql.rb
|
181
181
|
- db/migrations/20110311214833_add_appstats_results_db_connection.rb
|
182
182
|
- db/migrations/20110318203339_add_appstats_results_latest_flag.rb
|
183
|
+
- db/migrations/20110321154125_add_appstats_results_query_duration_in_seconds.rb
|
183
184
|
- db/schema.rb
|
184
185
|
- lib/appstats.rb
|
185
186
|
- lib/appstats/action.rb
|
@@ -192,6 +193,7 @@ files:
|
|
192
193
|
- lib/appstats/date_range.rb
|
193
194
|
- lib/appstats/entry.rb
|
194
195
|
- lib/appstats/entry_date.rb
|
196
|
+
- lib/appstats/friendly_timer.rb
|
195
197
|
- lib/appstats/host.rb
|
196
198
|
- lib/appstats/log_collector.rb
|
197
199
|
- lib/appstats/logger.rb
|
@@ -234,6 +236,7 @@ files:
|
|
234
236
|
- spec/date_range_spec.rb
|
235
237
|
- spec/entry_date_spec.rb
|
236
238
|
- spec/entry_spec.rb
|
239
|
+
- spec/friendly_timer_spec.rb
|
237
240
|
- spec/host_spec.rb
|
238
241
|
- spec/log_collector_spec.rb
|
239
242
|
- spec/logger_spec.rb
|
@@ -288,6 +291,7 @@ test_files:
|
|
288
291
|
- spec/date_range_spec.rb
|
289
292
|
- spec/entry_date_spec.rb
|
290
293
|
- spec/entry_spec.rb
|
294
|
+
- spec/friendly_timer_spec.rb
|
291
295
|
- spec/host_spec.rb
|
292
296
|
- spec/log_collector_spec.rb
|
293
297
|
- spec/logger_spec.rb
|