appstats 0.20.10 → 0.20.11
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile.lock +49 -49
- data/Gemfile.lock.rails2 +122 -0
- data/Rakefile +2 -1
- data/lib/appstats.rb +5 -0
- data/lib/appstats/entry.rb +2 -3
- data/lib/appstats/log_collector.rb +3 -3
- data/lib/appstats/query.rb +10 -5
- data/lib/appstats/result_job.rb +1 -1
- data/lib/appstats/version.rb +1 -1
- data/spec/appstats_query_spec.rb +1 -1
- data/spec/context_spec.rb +1 -1
- data/spec/entry_spec.rb +8 -8
- data/spec/logger_spec.rb +22 -22
- data/spec/query_spec.rb +5 -4
- data/spec/result_job_spec.rb +0 -4
- metadata +5 -5
- data/.rvmrc +0 -1
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
appstats (0.20.
|
4
|
+
appstats (0.20.11)
|
5
5
|
daemons
|
6
6
|
net-scp
|
7
7
|
rails (>= 2.3.0)
|
@@ -10,35 +10,35 @@ GEM
|
|
10
10
|
remote: http://rubygems.org/
|
11
11
|
specs:
|
12
12
|
Saikuro (1.1.0)
|
13
|
-
ZenTest (4.
|
13
|
+
ZenTest (4.5.0)
|
14
14
|
abstract (1.0.0)
|
15
|
-
actionmailer (3.0.
|
16
|
-
actionpack (= 3.0.
|
17
|
-
mail (~> 2.2.
|
18
|
-
actionpack (3.0.
|
19
|
-
activemodel (= 3.0.
|
20
|
-
activesupport (= 3.0.
|
15
|
+
actionmailer (3.0.7)
|
16
|
+
actionpack (= 3.0.7)
|
17
|
+
mail (~> 2.2.15)
|
18
|
+
actionpack (3.0.7)
|
19
|
+
activemodel (= 3.0.7)
|
20
|
+
activesupport (= 3.0.7)
|
21
21
|
builder (~> 2.1.2)
|
22
22
|
erubis (~> 2.6.6)
|
23
|
-
i18n (~> 0.
|
23
|
+
i18n (~> 0.5.0)
|
24
24
|
rack (~> 1.2.1)
|
25
|
-
rack-mount (~> 0.6.
|
26
|
-
rack-test (~> 0.5.
|
25
|
+
rack-mount (~> 0.6.14)
|
26
|
+
rack-test (~> 0.5.7)
|
27
27
|
tzinfo (~> 0.3.23)
|
28
|
-
activemodel (3.0.
|
29
|
-
activesupport (= 3.0.
|
28
|
+
activemodel (3.0.7)
|
29
|
+
activesupport (= 3.0.7)
|
30
30
|
builder (~> 2.1.2)
|
31
|
-
i18n (~> 0.
|
32
|
-
activerecord (3.0.
|
33
|
-
activemodel (= 3.0.
|
34
|
-
activesupport (= 3.0.
|
31
|
+
i18n (~> 0.5.0)
|
32
|
+
activerecord (3.0.7)
|
33
|
+
activemodel (= 3.0.7)
|
34
|
+
activesupport (= 3.0.7)
|
35
35
|
arel (~> 2.0.2)
|
36
36
|
tzinfo (~> 0.3.23)
|
37
|
-
activeresource (3.0.
|
38
|
-
activemodel (= 3.0.
|
39
|
-
activesupport (= 3.0.
|
40
|
-
activesupport (3.0.
|
41
|
-
arel (2.0.
|
37
|
+
activeresource (3.0.7)
|
38
|
+
activemodel (= 3.0.7)
|
39
|
+
activesupport (= 3.0.7)
|
40
|
+
activesupport (3.0.7)
|
41
|
+
arel (2.0.9)
|
42
42
|
arrayfields (4.7.4)
|
43
43
|
builder (2.1.2)
|
44
44
|
chronic (0.3.0)
|
@@ -50,7 +50,7 @@ GEM
|
|
50
50
|
ruby_parser (~> 2.0.4)
|
51
51
|
sexp_processor (~> 3.0.3)
|
52
52
|
colored (1.2)
|
53
|
-
daemons (1.1.
|
53
|
+
daemons (1.1.2)
|
54
54
|
diff-lcs (1.1.2)
|
55
55
|
erubis (2.6.6)
|
56
56
|
abstract (>= 1.0.0)
|
@@ -62,10 +62,10 @@ GEM
|
|
62
62
|
ruby_parser (~> 2.0)
|
63
63
|
sexp_processor (~> 3.0)
|
64
64
|
haml (3.0.25)
|
65
|
-
hirb (0.4.
|
65
|
+
hirb (0.4.3)
|
66
66
|
i18n (0.5.0)
|
67
67
|
json_pure (1.5.1)
|
68
|
-
mail (2.2.
|
68
|
+
mail (2.2.17)
|
69
69
|
activesupport (>= 2.3.6)
|
70
70
|
i18n (>= 0.4.0)
|
71
71
|
mime-types (~> 1.16)
|
@@ -89,22 +89,22 @@ GEM
|
|
89
89
|
mysql (2.8.1)
|
90
90
|
net-scp (1.0.4)
|
91
91
|
net-ssh (>= 1.99.1)
|
92
|
-
net-ssh (2.1.
|
92
|
+
net-ssh (2.1.4)
|
93
93
|
polyglot (0.3.1)
|
94
|
-
rack (1.2.
|
95
|
-
rack-mount (0.6.
|
94
|
+
rack (1.2.2)
|
95
|
+
rack-mount (0.6.14)
|
96
96
|
rack (>= 1.0.0)
|
97
97
|
rack-test (0.5.7)
|
98
98
|
rack (>= 1.0)
|
99
|
-
rails (3.0.
|
100
|
-
actionmailer (= 3.0.
|
101
|
-
actionpack (= 3.0.
|
102
|
-
activerecord (= 3.0.
|
103
|
-
activeresource (= 3.0.
|
104
|
-
activesupport (= 3.0.
|
99
|
+
rails (3.0.7)
|
100
|
+
actionmailer (= 3.0.7)
|
101
|
+
actionpack (= 3.0.7)
|
102
|
+
activerecord (= 3.0.7)
|
103
|
+
activeresource (= 3.0.7)
|
104
|
+
activesupport (= 3.0.7)
|
105
105
|
bundler (~> 1.0)
|
106
|
-
railties (= 3.0.
|
107
|
-
rails_best_practices (0.7.
|
106
|
+
railties (= 3.0.7)
|
107
|
+
rails_best_practices (0.7.5)
|
108
108
|
activesupport
|
109
109
|
colored (~> 1.2)
|
110
110
|
erubis (~> 2.6.6)
|
@@ -112,9 +112,9 @@ GEM
|
|
112
112
|
i18n
|
113
113
|
ruby-progressbar (~> 0.0.9)
|
114
114
|
ruby_parser (~> 2.0.4)
|
115
|
-
railties (3.0.
|
116
|
-
actionpack (= 3.0.
|
117
|
-
activesupport (= 3.0.
|
115
|
+
railties (3.0.7)
|
116
|
+
actionpack (= 3.0.7)
|
117
|
+
activesupport (= 3.0.7)
|
118
118
|
rake (>= 0.8.7)
|
119
119
|
thor (~> 0.14.4)
|
120
120
|
rake (0.8.7)
|
@@ -125,29 +125,29 @@ GEM
|
|
125
125
|
sexp_processor (~> 3.0)
|
126
126
|
roodi (2.1.0)
|
127
127
|
ruby_parser
|
128
|
-
rspec (2.
|
129
|
-
rspec-core (~> 2.
|
130
|
-
rspec-expectations (~> 2.
|
131
|
-
rspec-mocks (~> 2.
|
132
|
-
rspec-core (2.
|
133
|
-
rspec-expectations (2.
|
128
|
+
rspec (2.5.0)
|
129
|
+
rspec-core (~> 2.5.0)
|
130
|
+
rspec-expectations (~> 2.5.0)
|
131
|
+
rspec-mocks (~> 2.5.0)
|
132
|
+
rspec-core (2.5.1)
|
133
|
+
rspec-expectations (2.5.0)
|
134
134
|
diff-lcs (~> 1.1.2)
|
135
|
-
rspec-mocks (2.
|
136
|
-
ruby-progressbar (0.0.
|
135
|
+
rspec-mocks (2.5.0)
|
136
|
+
ruby-progressbar (0.0.10)
|
137
137
|
ruby2ruby (1.2.5)
|
138
138
|
ruby_parser (~> 2.0)
|
139
139
|
sexp_processor (~> 3.0)
|
140
140
|
ruby_parser (2.0.6)
|
141
141
|
sexp_processor (~> 3.0)
|
142
142
|
sexp_processor (3.0.5)
|
143
|
-
standalone_migrations (0.
|
143
|
+
standalone_migrations (0.4.7)
|
144
144
|
activerecord
|
145
145
|
rake
|
146
146
|
syntax (1.0.0)
|
147
147
|
thor (0.14.6)
|
148
148
|
treetop (1.4.9)
|
149
149
|
polyglot (>= 0.3.1)
|
150
|
-
tzinfo (0.3.
|
150
|
+
tzinfo (0.3.26)
|
151
151
|
|
152
152
|
PLATFORMS
|
153
153
|
ruby
|
data/Gemfile.lock.rails2
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
appstats (0.20.11)
|
5
|
+
daemons
|
6
|
+
net-scp
|
7
|
+
rails (>= 2.3.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: http://rubygems.org/
|
11
|
+
specs:
|
12
|
+
Saikuro (1.1.0)
|
13
|
+
ZenTest (4.5.0)
|
14
|
+
abstract (1.0.0)
|
15
|
+
actionmailer (2.3.11)
|
16
|
+
actionpack (= 2.3.11)
|
17
|
+
actionpack (2.3.11)
|
18
|
+
activesupport (= 2.3.11)
|
19
|
+
rack (~> 1.1.0)
|
20
|
+
activerecord (2.3.11)
|
21
|
+
activesupport (= 2.3.11)
|
22
|
+
activeresource (2.3.11)
|
23
|
+
activesupport (= 2.3.11)
|
24
|
+
activesupport (2.3.11)
|
25
|
+
arrayfields (4.7.4)
|
26
|
+
chronic (0.3.0)
|
27
|
+
churn (0.0.13)
|
28
|
+
chronic (>= 0.2.3)
|
29
|
+
hirb
|
30
|
+
json_pure
|
31
|
+
main
|
32
|
+
ruby_parser (~> 2.0.4)
|
33
|
+
sexp_processor (~> 3.0.3)
|
34
|
+
colored (1.2)
|
35
|
+
daemons (1.1.2)
|
36
|
+
diff-lcs (1.1.2)
|
37
|
+
erubis (2.6.6)
|
38
|
+
abstract (>= 1.0.0)
|
39
|
+
fattr (2.2.0)
|
40
|
+
flay (1.4.2)
|
41
|
+
ruby_parser (~> 2.0)
|
42
|
+
sexp_processor (~> 3.0)
|
43
|
+
flog (2.5.1)
|
44
|
+
ruby_parser (~> 2.0)
|
45
|
+
sexp_processor (~> 3.0)
|
46
|
+
haml (3.0.25)
|
47
|
+
hirb (0.4.3)
|
48
|
+
i18n (0.5.0)
|
49
|
+
json_pure (1.5.1)
|
50
|
+
main (4.4.0)
|
51
|
+
arrayfields (>= 4.7.4)
|
52
|
+
fattr (>= 2.1.0)
|
53
|
+
metric_fu (2.1.1)
|
54
|
+
Saikuro (>= 1.1.0)
|
55
|
+
activesupport (>= 2.0.0)
|
56
|
+
chronic (~> 0.3.0)
|
57
|
+
churn (>= 0.0.7)
|
58
|
+
flay (>= 1.2.1)
|
59
|
+
flog (>= 2.3.0)
|
60
|
+
rails_best_practices (>= 0.6.4)
|
61
|
+
rcov (>= 0.8.3.3)
|
62
|
+
reek (>= 1.2.6)
|
63
|
+
roodi (>= 2.1.0)
|
64
|
+
syntax
|
65
|
+
mysql (2.8.1)
|
66
|
+
net-scp (1.0.4)
|
67
|
+
net-ssh (>= 1.99.1)
|
68
|
+
net-ssh (2.1.4)
|
69
|
+
rack (1.1.2)
|
70
|
+
rails (2.3.11)
|
71
|
+
actionmailer (= 2.3.11)
|
72
|
+
actionpack (= 2.3.11)
|
73
|
+
activerecord (= 2.3.11)
|
74
|
+
activeresource (= 2.3.11)
|
75
|
+
activesupport (= 2.3.11)
|
76
|
+
rake (>= 0.8.3)
|
77
|
+
rails_best_practices (0.7.5)
|
78
|
+
activesupport
|
79
|
+
colored (~> 1.2)
|
80
|
+
erubis (~> 2.6.6)
|
81
|
+
haml (~> 3.0.18)
|
82
|
+
i18n
|
83
|
+
ruby-progressbar (~> 0.0.9)
|
84
|
+
ruby_parser (~> 2.0.4)
|
85
|
+
rake (0.8.7)
|
86
|
+
rcov (0.9.9)
|
87
|
+
reek (1.2.8)
|
88
|
+
ruby2ruby (~> 1.2)
|
89
|
+
ruby_parser (~> 2.0)
|
90
|
+
sexp_processor (~> 3.0)
|
91
|
+
roodi (2.1.0)
|
92
|
+
ruby_parser
|
93
|
+
rspec (2.5.0)
|
94
|
+
rspec-core (~> 2.5.0)
|
95
|
+
rspec-expectations (~> 2.5.0)
|
96
|
+
rspec-mocks (~> 2.5.0)
|
97
|
+
rspec-core (2.5.1)
|
98
|
+
rspec-expectations (2.5.0)
|
99
|
+
diff-lcs (~> 1.1.2)
|
100
|
+
rspec-mocks (2.5.0)
|
101
|
+
ruby-progressbar (0.0.10)
|
102
|
+
ruby2ruby (1.2.5)
|
103
|
+
ruby_parser (~> 2.0)
|
104
|
+
sexp_processor (~> 3.0)
|
105
|
+
ruby_parser (2.0.6)
|
106
|
+
sexp_processor (~> 3.0)
|
107
|
+
sexp_processor (3.0.5)
|
108
|
+
standalone_migrations (0.4.5)
|
109
|
+
activerecord
|
110
|
+
rake
|
111
|
+
syntax (1.0.0)
|
112
|
+
|
113
|
+
PLATFORMS
|
114
|
+
ruby
|
115
|
+
|
116
|
+
DEPENDENCIES
|
117
|
+
ZenTest
|
118
|
+
appstats!
|
119
|
+
metric_fu
|
120
|
+
mysql
|
121
|
+
rspec
|
122
|
+
standalone_migrations
|
data/Rakefile
CHANGED
data/lib/appstats.rb
CHANGED
data/lib/appstats/entry.rb
CHANGED
@@ -51,7 +51,6 @@ module Appstats
|
|
51
51
|
def self.create_from_logger_string(action_and_contexts)
|
52
52
|
return false if action_and_contexts.nil? || action_and_contexts == ''
|
53
53
|
hash = Logger.entry_to_hash(action_and_contexts)
|
54
|
-
|
55
54
|
action_name = hash[:action].kind_of?(Array) ? hash[:action][0] : hash[:action]
|
56
55
|
entry = Appstats::Entry.new(:action => action_name, :raw_entry => action_and_contexts)
|
57
56
|
entry.occurred_at = Time.parse(hash[:timestamp]) unless hash[:timestamp].nil?
|
@@ -61,8 +60,8 @@ module Appstats
|
|
61
60
|
if key == :action
|
62
61
|
all_values = all_values[1..-1]
|
63
62
|
end
|
64
|
-
all_values.each do |
|
65
|
-
context = Appstats::Context.create(:context_key => key, :context_value =>
|
63
|
+
all_values.each do |v|
|
64
|
+
context = Appstats::Context.create(:context_key => key.to_s, :context_value => v)
|
66
65
|
entry.contexts<< context
|
67
66
|
end
|
68
67
|
end
|
@@ -89,7 +89,7 @@ module Appstats
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def self.download_remote_files(raw_logins)
|
92
|
-
all = LogCollector.where("status = 'unprocessed'").all
|
92
|
+
all = Appstats.rails3? ? LogCollector.where("status = 'unprocessed'").all : LogCollector.find(:all,:conditions => "status = 'unprocessed'")
|
93
93
|
if all.empty?
|
94
94
|
Appstats.log(:info,"No remote logs to download.")
|
95
95
|
return 0
|
@@ -127,7 +127,7 @@ module Appstats
|
|
127
127
|
end
|
128
128
|
|
129
129
|
def self.process_local_files
|
130
|
-
all = LogCollector.where("status = 'downloaded'").all
|
130
|
+
all = Appstats.rails3? ? LogCollector.where("status = 'downloaded'").all : LogCollector.find(:all, :conditions => "status = 'downloaded'")
|
131
131
|
if all.empty?
|
132
132
|
Appstats.log(:info,"No local logs to process.")
|
133
133
|
return 0
|
@@ -159,7 +159,7 @@ module Appstats
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def self.remove_remote_files(raw_logins)
|
162
|
-
all = LogCollector.where("status = 'processed'").all
|
162
|
+
all = Appstats.rails3? ? LogCollector.where("status = 'processed'").all : LogCollector.find(:all,:conditions => "status = 'processed'")
|
163
163
|
if all.empty?
|
164
164
|
Appstats.log(:info,"No remote logs to remove.")
|
165
165
|
return 0
|
data/lib/appstats/query.rb
CHANGED
@@ -36,13 +36,13 @@ module Appstats
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def find(job_frequency_if_not_available = 'once')
|
39
|
-
result = Appstats::Result.where("query = ? and is_latest = 1",@query).first
|
39
|
+
result = Appstats.rails3? ? Appstats::Result.where("query = ? and is_latest = 1",@query).first : Appstats::Result.find(:first,:conditions => [ "query = ? and is_latest = 1",@query ])
|
40
40
|
if result.nil?
|
41
41
|
if job_frequency_if_not_available.nil?
|
42
42
|
result = run
|
43
43
|
else
|
44
44
|
job_frequency_if_not_available = "once" if job_frequency_if_not_available == true
|
45
|
-
existing = Appstats::ResultJob.where("query = ? and (last_run_at is null or frequency <> 'once')",@query).first
|
45
|
+
existing = Appstats.rails3? ? Appstats::ResultJob.where("query = ? and (last_run_at is null or frequency <> 'once')",@query).first : Appstats::ResultJob.find(:first,:conditions => [ "query = ? and (last_run_at is null or frequency <> 'once')",@query ])
|
46
46
|
if existing.nil?
|
47
47
|
Appstats::ResultJob.create(:name => "Missing Query#find requested", :frequency => job_frequency_if_not_available, :query => @query, :query_type => @query_type)
|
48
48
|
end
|
@@ -109,7 +109,11 @@ module Appstats
|
|
109
109
|
end
|
110
110
|
|
111
111
|
if @operation == "#!"
|
112
|
-
|
112
|
+
if Appstats.rails3?
|
113
|
+
Result.where("(query = ? or query = ?) and id <> ?",@query,@query.sub("#!","#"),result.id).delete_all
|
114
|
+
else
|
115
|
+
Result.delete_all(["(query = ? or query = ?) and id <> ?",@query,@query.sub("#!","#"),result.id])
|
116
|
+
end
|
113
117
|
result.save
|
114
118
|
end
|
115
119
|
|
@@ -219,17 +223,18 @@ module Appstats
|
|
219
223
|
db_config = ActiveRecord::Base.connection.instance_variable_get(:@config)
|
220
224
|
restore_connection
|
221
225
|
data = { :results => results, :db_config => db_config, :duration => timer.duration }
|
226
|
+
return data
|
222
227
|
rescue Exception => e
|
223
228
|
restore_connection
|
224
229
|
Appstats.log(:error,"Something bad occurred during Appstats::#{query_type}#run_query")
|
225
230
|
Appstats.log(:error,e.message)
|
226
|
-
nil
|
231
|
+
return nil
|
227
232
|
end
|
228
233
|
end
|
229
234
|
|
230
235
|
|
231
236
|
def normalize_action_name(action_name)
|
232
|
-
action = Appstats::Action.where("plural_name = ?",action_name).first
|
237
|
+
action = Appstats.rails3? ? Appstats::Action.where("plural_name = ?",action_name).first : Appstats::Action.find(:first,:conditions => [ "plural_name = ?",action_name ])
|
233
238
|
action.nil? ? action_name : action.name
|
234
239
|
end
|
235
240
|
|
data/lib/appstats/result_job.rb
CHANGED
@@ -42,7 +42,7 @@ module Appstats
|
|
42
42
|
|
43
43
|
def self.run
|
44
44
|
count = 0
|
45
|
-
all = ResultJob.where("frequency <> 'once' or last_run_at IS NULL").all
|
45
|
+
all = Appstats.rails3? ? ResultJob.where("frequency <> 'once' or last_run_at IS NULL").all : ResultJob.find(:all, :conditions => "frequency <> 'once' or last_run_at IS NULL")
|
46
46
|
if all.size == 0
|
47
47
|
Appstats.log(:info, "No result jobs to run.")
|
48
48
|
return count
|
data/lib/appstats/version.rb
CHANGED
data/spec/appstats_query_spec.rb
CHANGED
@@ -130,7 +130,7 @@ module Appstats
|
|
130
130
|
|
131
131
|
describe "# booms" do
|
132
132
|
|
133
|
-
it "should return nil results" do
|
133
|
+
it "should return nil results (catch the exception)" do
|
134
134
|
@appstats_query.query = Appstats::Query.new(:query => "# booms", :query_type => "Appstats::AppstatsQuery")
|
135
135
|
@appstats_query.process_query
|
136
136
|
@appstats_query.query_to_sql.should == "invalid sql"
|
data/spec/context_spec.rb
CHANGED
@@ -27,7 +27,7 @@ module Appstats
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should set on constructor" do
|
30
|
-
context = Appstats::Context.new(:context_key => 'a', :context_value => "b"
|
30
|
+
context = Appstats::Context.new(:context_key => 'a', :context_value => "b")
|
31
31
|
context.context_key.should == 'a'
|
32
32
|
context.context_value.should == 'b'
|
33
33
|
context.context_int.should == nil
|
data/spec/entry_spec.rb
CHANGED
@@ -193,18 +193,18 @@ module Appstats
|
|
193
193
|
end
|
194
194
|
|
195
195
|
it "should understand an entry without contexts" do
|
196
|
-
entry = Entry.create_from_logger_string("0.20.
|
196
|
+
entry = Entry.create_from_logger_string("0.20.11 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search")
|
197
197
|
Entry.count.should == @before_count + 1
|
198
198
|
entry.action.should == "address_search"
|
199
|
-
entry.raw_entry.should == "0.20.
|
199
|
+
entry.raw_entry.should == "0.20.11 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search"
|
200
200
|
entry.occurred_at.should == Time.parse("2010-09-21 23:15:20")
|
201
201
|
end
|
202
202
|
|
203
203
|
it "should understand contexts" do
|
204
|
-
entry = Entry.create_from_logger_string("0.20.
|
204
|
+
entry = Entry.create_from_logger_string("0.20.11 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live")
|
205
205
|
Entry.count.should == @before_count + 1
|
206
206
|
entry.action.should == "address_filter"
|
207
|
-
entry.raw_entry.should == "0.20.
|
207
|
+
entry.raw_entry.should == "0.20.11 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live"
|
208
208
|
entry.occurred_at.should == Time.parse("2010-09-21 23:15:20")
|
209
209
|
entry.contexts.size.should == 2
|
210
210
|
entry.contexts[0].context_key = "app_name"
|
@@ -214,10 +214,10 @@ module Appstats
|
|
214
214
|
end
|
215
215
|
|
216
216
|
it "should handle 'action' as a context" do
|
217
|
-
entry = Entry.create_from_logger_string('0.20.
|
217
|
+
entry = Entry.create_from_logger_string('0.20.11 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : action=save_ovcen : app_name=cdb')
|
218
218
|
Entry.count.should == @before_count + 1
|
219
219
|
entry.action.should == "page-view"
|
220
|
-
entry.raw_entry.should == "0.20.
|
220
|
+
entry.raw_entry.should == "0.20.11 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : action=save_ovcen : app_name=cdb"
|
221
221
|
entry.occurred_at.should == Time.parse("2011-02-24 12:59:57")
|
222
222
|
entry.contexts.size.should == 2
|
223
223
|
entry.contexts[0].context_key = "action"
|
@@ -228,10 +228,10 @@ module Appstats
|
|
228
228
|
end
|
229
229
|
|
230
230
|
it "should handle multiple of the same 'context'" do
|
231
|
-
entry = Entry.create_from_logger_string('0.20.
|
231
|
+
entry = Entry.create_from_logger_string('0.20.11 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : app_name=market : app_name=cdb')
|
232
232
|
Entry.count.should == @before_count + 1
|
233
233
|
entry.action.should == "page-view"
|
234
|
-
entry.raw_entry.should == "0.20.
|
234
|
+
entry.raw_entry.should == "0.20.11 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : app_name=market : app_name=cdb"
|
235
235
|
entry.occurred_at.should == Time.parse("2011-02-24 12:59:57")
|
236
236
|
entry.contexts.size.should == 2
|
237
237
|
entry.contexts[0].context_key = "app_name"
|
data/spec/logger_spec.rb
CHANGED
@@ -122,12 +122,12 @@ module Appstats
|
|
122
122
|
|
123
123
|
it "should accept numbers" do
|
124
124
|
Appstats::Logger.entry(5, :blah => 6)
|
125
|
-
Appstats::Logger.raw_read.should == ["0.20.
|
125
|
+
Appstats::Logger.raw_read.should == ["0.20.11 setup[:,=,-n] 2010-09-21 23:15:20 action=5 : blah=6"]
|
126
126
|
end
|
127
127
|
|
128
128
|
it "should accept arrays" do
|
129
129
|
Appstats::Logger.entry('search', :provider => [ 'one', 'two' ])
|
130
|
-
Appstats::Logger.raw_read.should == ["0.20.
|
130
|
+
Appstats::Logger.raw_read.should == ["0.20.11 setup[:,=,-n] 2010-09-21 23:15:20 action=search : provider=one : provider=two"]
|
131
131
|
end
|
132
132
|
|
133
133
|
|
@@ -137,7 +137,7 @@ module Appstats
|
|
137
137
|
|
138
138
|
it "should look similar to regular entry" do
|
139
139
|
Appstats::Logger.exception_entry(RuntimeError.new("blah"),:on => "login")
|
140
|
-
Appstats::Logger.raw_read.should == ["0.20.
|
140
|
+
Appstats::Logger.raw_read.should == ["0.20.11 setup[:,=,-n] 2010-09-21 23:15:20 action=appstats-exception : error=blah : on=login"]
|
141
141
|
end
|
142
142
|
|
143
143
|
end
|
@@ -154,47 +154,47 @@ module Appstats
|
|
154
154
|
|
155
155
|
it "should handle a statistics entry" do
|
156
156
|
expected = { :action => "address_search", :timestamp => "2010-09-21 23:15:20" }
|
157
|
-
actual = Appstats::Logger.entry_to_hash("0.20.
|
157
|
+
actual = Appstats::Logger.entry_to_hash("0.20.11 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search")
|
158
158
|
actual.should == expected
|
159
159
|
end
|
160
160
|
|
161
161
|
it "should handle contexts" do
|
162
162
|
expected = { :action => "address_filter", :timestamp => "2010-09-21 23:15:20", :server => "Live", :app_name => 'Market' }
|
163
|
-
actual = Appstats::Logger.entry_to_hash("0.20.
|
163
|
+
actual = Appstats::Logger.entry_to_hash("0.20.11 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live")
|
164
164
|
actual.should == expected
|
165
165
|
end
|
166
166
|
|
167
167
|
it "should handle multiple actions" do
|
168
168
|
expected = { :action => ["address_filter", "blah"], :timestamp => "2010-09-21 23:15:20", :server => "Live", :app_name => 'Market' }
|
169
|
-
actual = Appstats::Logger.entry_to_hash("0.20.
|
169
|
+
actual = Appstats::Logger.entry_to_hash("0.20.11 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : action=blah : app_name=Market : server=Live")
|
170
170
|
actual.should == expected
|
171
171
|
end
|
172
172
|
|
173
173
|
it "should handle multiple of same context" do
|
174
174
|
expected = { :action => "address_filter", :timestamp => "2010-09-21 23:15:20", :server => "Live", :app_name => ['Sin','Market'] }
|
175
|
-
actual = Appstats::Logger.entry_to_hash("0.20.
|
175
|
+
actual = Appstats::Logger.entry_to_hash("0.20.11 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Sin : app_name=Market : server=Live")
|
176
176
|
actual.should == expected
|
177
177
|
end
|
178
178
|
|
179
179
|
it "should handle no actions" do
|
180
180
|
expected = { :action => "UNKNOWN_ACTION", :timestamp => "2010-09-21 23:15:20", :server => "Live", :app_name => 'Market' }
|
181
|
-
actual = Appstats::Logger.entry_to_hash("0.20.
|
181
|
+
actual = Appstats::Logger.entry_to_hash("0.20.11 setup[:,=,-n] 2010-09-21 23:15:20 app_name=Market : server=Live")
|
182
182
|
actual.should == expected
|
183
183
|
end
|
184
184
|
|
185
185
|
it "should handle actions with the delimiter (and change the delimiter)" do
|
186
186
|
expected = { :action => "address:=search-n", :timestamp => "2010-09-21 23:15:20" }
|
187
|
-
actual = Appstats::Logger.entry_to_hash("0.20.
|
187
|
+
actual = Appstats::Logger.entry_to_hash("0.20.11 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=search-n")
|
188
188
|
actual.should == expected
|
189
189
|
|
190
190
|
expected = { :action => "address::search==--n", :timestamp => "2010-09-21 23:15:20" }
|
191
|
-
actual = Appstats::Logger.entry_to_hash("0.20.
|
191
|
+
actual = Appstats::Logger.entry_to_hash("0.20.11 setup[:::,===,---n] 2010-09-21 23:15:20 action===address::search==--n")
|
192
192
|
actual.should == expected
|
193
193
|
end
|
194
194
|
|
195
195
|
it "should handle contexts with the delimiter (and change the delimiter)" do
|
196
196
|
expected = { :action => "address", :timestamp => "2010-09-21 23:15:20", :server => "market:eval=-n" }
|
197
|
-
actual = Appstats::Logger.entry_to_hash("0.20.
|
197
|
+
actual = Appstats::Logger.entry_to_hash("0.20.11 setup[::,==,--n] 2010-09-21 23:15:20 action==address :: server==market:eval=-n")
|
198
198
|
actual.should == expected
|
199
199
|
end
|
200
200
|
|
@@ -203,66 +203,66 @@ module Appstats
|
|
203
203
|
describe "#entry_to_s" do
|
204
204
|
|
205
205
|
it "should handle a statistics entry" do
|
206
|
-
expected = "0.20.
|
206
|
+
expected = "0.20.11 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search"
|
207
207
|
actual = Appstats::Logger.entry_to_s("address_search")
|
208
208
|
actual.should == expected
|
209
209
|
end
|
210
210
|
|
211
211
|
it "should handle numbers" do
|
212
|
-
expected = "0.20.
|
212
|
+
expected = "0.20.11 setup[:,=,-n] 2010-09-21 23:15:20 action=1 : note=2.2"
|
213
213
|
actual = Appstats::Logger.entry_to_s(1,:note => 2.2)
|
214
214
|
actual.should == expected
|
215
215
|
end
|
216
216
|
|
217
217
|
it "should handle default contexts" do
|
218
218
|
Appstats::Logger.default_contexts[:app_name] = "market"
|
219
|
-
expected = "0.20.
|
219
|
+
expected = "0.20.11 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search : app_name=market"
|
220
220
|
actual = Appstats::Logger.entry_to_s("address_search")
|
221
221
|
actual.should == expected
|
222
222
|
end
|
223
223
|
|
224
224
|
it "should handle contexts (and sort them by symbol)" do
|
225
|
-
expected = "0.20.
|
225
|
+
expected = "0.20.11 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live"
|
226
226
|
actual = Appstats::Logger.entry_to_s("address_filter", { :server => "Live", :app_name => 'Market' })
|
227
227
|
actual.should == expected
|
228
228
|
end
|
229
229
|
|
230
230
|
it "should handle actions with the delimiter (and change the delimiter)" do
|
231
|
-
expected = "0.20.
|
231
|
+
expected = "0.20.11 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=search-n"
|
232
232
|
actual = Appstats::Logger.entry_to_s("address:=search-n")
|
233
233
|
actual.should == expected
|
234
234
|
|
235
|
-
expected = "0.20.
|
235
|
+
expected = "0.20.11 setup[:::,===,---n] 2010-09-21 23:15:20 action===address::search==--n"
|
236
236
|
actual = Appstats::Logger.entry_to_s("address::search==--n")
|
237
237
|
actual.should == expected
|
238
238
|
end
|
239
239
|
|
240
240
|
it "should handle contexts with the delimiter (and change the delimiter)" do
|
241
|
-
expected = "0.20.
|
241
|
+
expected = "0.20.11 setup[::,==,--n] 2010-09-21 23:15:20 action==address :: server==market:eval=-n"
|
242
242
|
actual = Appstats::Logger.entry_to_s("address", :server => 'market:eval=-n')
|
243
243
|
actual.should == expected
|
244
244
|
end
|
245
245
|
|
246
246
|
it "should ignore spaces" do
|
247
|
-
expected = "0.20.
|
247
|
+
expected = "0.20.11 setup[:,=,-n] 2010-09-21 23:15:20 action=address search"
|
248
248
|
actual = Appstats::Logger.entry_to_s("address search")
|
249
249
|
actual.should == expected
|
250
250
|
end
|
251
251
|
|
252
252
|
it "should convert newlines in action" do
|
253
|
-
expected = "0.20.
|
253
|
+
expected = "0.20.11 setup[:,=,-n] 2010-09-21 23:15:20 action=address_-nsearch"
|
254
254
|
actual = Appstats::Logger.entry_to_s("address_\nsearch")
|
255
255
|
actual.should == expected
|
256
256
|
end
|
257
257
|
|
258
258
|
it "should convert newlines in context" do
|
259
|
-
expected = "0.20.
|
259
|
+
expected = "0.20.11 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search : blah=some-nlong-nstatement"
|
260
260
|
actual = Appstats::Logger.entry_to_s("address_search",:blah => "some\nlong\nstatement")
|
261
261
|
actual.should == expected
|
262
262
|
end
|
263
263
|
|
264
264
|
it "should convert newlines based on the delimiter" do
|
265
|
-
expected = "0.20.
|
265
|
+
expected = "0.20.11 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=--nsearch-n"
|
266
266
|
actual = Appstats::Logger.entry_to_s("address:=\nsearch-n")
|
267
267
|
actual.should == expected
|
268
268
|
end
|
data/spec/query_spec.rb
CHANGED
@@ -529,7 +529,7 @@ module Appstats
|
|
529
529
|
[result.db_username,result.db_name,result.db_host].should == ['root','appstats_development','localhost']
|
530
530
|
end
|
531
531
|
|
532
|
-
it "should handle group by when core search has errors
|
532
|
+
it "should handle group by when core search has errors" do
|
533
533
|
TestObject.create and TestObject.create
|
534
534
|
|
535
535
|
query = Query.new(:query => "# x group by y", :query_type => "Appstats::BadTestQuery")
|
@@ -579,11 +579,12 @@ module Appstats
|
|
579
579
|
query2 = Query.new(:query => "# x on otherServer", :query_type => "Appstats::TestQuery")
|
580
580
|
result2 = query2.run
|
581
581
|
|
582
|
-
if
|
582
|
+
if result1.count == result2.count #coincidence
|
583
583
|
TestObject.create(:name => "aa")
|
584
|
-
|
584
|
+
query1 = Query.new(:query => "# x on testServer", :query_type => "Appstats::TestQuery")
|
585
|
+
result1 = query1.run
|
585
586
|
end
|
586
|
-
|
587
|
+
|
587
588
|
result1.count.should_not == result2.count
|
588
589
|
|
589
590
|
result1 = query1.run
|
data/spec/result_job_spec.rb
CHANGED
@@ -339,10 +339,6 @@ module Appstats
|
|
339
339
|
Appstats::ResultJob.run.should == 1
|
340
340
|
end
|
341
341
|
|
342
|
-
it "should filter out 'once' with a date" do
|
343
|
-
|
344
|
-
end
|
345
|
-
|
346
342
|
it "should create results" do
|
347
343
|
job1 = Appstats::ResultJob.create(:name => "x", :query => "# blahs", :frequency => "once")
|
348
344
|
job2 = Appstats::ResultJob.create(:name => "y", :query => "# blahs where type=1", :frequency => "once")
|
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: 89
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 20
|
9
|
-
-
|
10
|
-
version: 0.20.
|
9
|
+
- 11
|
10
|
+
version: 0.20.11
|
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-04-
|
18
|
+
date: 2011-04-19 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -143,9 +143,9 @@ extra_rdoc_files: []
|
|
143
143
|
|
144
144
|
files:
|
145
145
|
- .gitignore
|
146
|
-
- .rvmrc
|
147
146
|
- Gemfile
|
148
147
|
- Gemfile.lock
|
148
|
+
- Gemfile.lock.rails2
|
149
149
|
- History.txt
|
150
150
|
- README.rdoc
|
151
151
|
- Rakefile
|
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm 1.8.7-p248@appstats --create
|