appstats 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/appstats.rb +1 -1
- data/lib/appstats/entry.rb +7 -3
- data/lib/appstats/log_collector.rb +1 -1
- data/lib/appstats/query.rb +8 -5
- data/lib/appstats/version.rb +1 -1
- data/spec/entry_spec.rb +30 -12
- data/spec/logger_spec.rb +18 -18
- data/spec/query_spec.rb +40 -9
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/lib/appstats.rb
CHANGED
@@ -10,10 +10,10 @@ require "#{File.dirname(__FILE__)}/appstats/context"
|
|
10
10
|
require "#{File.dirname(__FILE__)}/appstats/tasks"
|
11
11
|
require "#{File.dirname(__FILE__)}/appstats/logger"
|
12
12
|
require "#{File.dirname(__FILE__)}/appstats/log_collector"
|
13
|
+
require "#{File.dirname(__FILE__)}/appstats/parser"
|
13
14
|
require "#{File.dirname(__FILE__)}/appstats/query"
|
14
15
|
require "#{File.dirname(__FILE__)}/appstats/result"
|
15
16
|
require "#{File.dirname(__FILE__)}/appstats/host"
|
16
|
-
require "#{File.dirname(__FILE__)}/appstats/parser"
|
17
17
|
require "#{File.dirname(__FILE__)}/appstats/test_object"
|
18
18
|
|
19
19
|
# required in the appstats.gemspec
|
data/lib/appstats/entry.rb
CHANGED
@@ -35,16 +35,16 @@ module Appstats
|
|
35
35
|
"#{action} at #{occurred_at.strftime('%Y-%m-%d %H:%M:%S')}"
|
36
36
|
end
|
37
37
|
|
38
|
-
def self.
|
38
|
+
def self.create_from_logger_file(filename)
|
39
39
|
return false if filename.nil?
|
40
40
|
return false unless File.exists?(filename)
|
41
41
|
File.open(filename,"r").readlines.each do |line|
|
42
|
-
|
42
|
+
create_from_logger_string(line.strip)
|
43
43
|
end
|
44
44
|
true
|
45
45
|
end
|
46
46
|
|
47
|
-
def self.
|
47
|
+
def self.create_from_logger_string(action_and_contexts)
|
48
48
|
return false if action_and_contexts.nil? || action_and_contexts == ''
|
49
49
|
hash = Logger.entry_to_hash(action_and_contexts)
|
50
50
|
entry = Appstats::Entry.new(:action => hash[:action], :raw_entry => action_and_contexts)
|
@@ -59,6 +59,10 @@ module Appstats
|
|
59
59
|
entry
|
60
60
|
end
|
61
61
|
|
62
|
+
def self.create_from_logger(action,contexts = {})
|
63
|
+
return false if action.nil? || action.blank?
|
64
|
+
create_from_logger_string(Logger.entry_to_s(action,contexts))
|
65
|
+
end
|
62
66
|
|
63
67
|
private
|
64
68
|
|
@@ -102,7 +102,7 @@ module Appstats
|
|
102
102
|
current_entries = 0
|
103
103
|
begin
|
104
104
|
File.open(log_collector.local_filename,"r").readlines.each do |line|
|
105
|
-
entry = Entry.
|
105
|
+
entry = Entry.create_from_logger_string(line.strip)
|
106
106
|
entry.log_collector = log_collector
|
107
107
|
entry.save
|
108
108
|
current_entries += 1
|
data/lib/appstats/query.rb
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
module Appstats
|
3
3
|
class Query
|
4
4
|
|
5
|
+
@@language_parser = Appstats::Parser.new(:rules => ":operation :action :date on :host where :contexts")
|
6
|
+
@@contexts_parser = Appstats::Parser.new(:rules => ":context", :repeating => true, :tokenize => "and or || && = <= >= <> != ( ) like")
|
7
|
+
|
5
8
|
@@nill_query = "select 0 from appstats_entries LIMIT 1"
|
6
9
|
@@default = "1=1"
|
7
10
|
attr_accessor :query, :action, :host, :date_range, :query_to_sql, :contexts
|
@@ -33,7 +36,7 @@ module Appstats
|
|
33
36
|
end
|
34
37
|
|
35
38
|
def self.contexts_filter_to_sql(raw_input)
|
36
|
-
context_parser =
|
39
|
+
context_parser = @@contexts_parser.dup
|
37
40
|
return @@default if (raw_input.blank? || !context_parser.parse(raw_input))
|
38
41
|
sql = "EXISTS (select * from appstats_contexts where appstats_entries.id = appstats_contexts.appstats_entry_id and ("
|
39
42
|
|
@@ -54,10 +57,10 @@ module Appstats
|
|
54
57
|
end
|
55
58
|
if status == :next
|
56
59
|
status = :waiting_comparator
|
57
|
-
sql += " (context_key='#{sqlclean(entry[:context])}'"
|
60
|
+
sql += " (context_key = '#{sqlclean(entry[:context])}'"
|
58
61
|
else
|
59
62
|
status = :next
|
60
|
-
sql += " and context_value#{comparator}'#{sqlclean(entry[:context])}')"
|
63
|
+
sql += " and context_value #{comparator} '#{sqlclean(entry[:context])}')"
|
61
64
|
end
|
62
65
|
end
|
63
66
|
sql += ")" if status == :waiting_comparator
|
@@ -82,7 +85,7 @@ module Appstats
|
|
82
85
|
|
83
86
|
def self.comparator?(raw_input)
|
84
87
|
return false if raw_input.nil?
|
85
|
-
["=","!=","<>",">","<",">=","<="].include?(raw_input)
|
88
|
+
["=","!=","<>",">","<",">=","<=","like"].include?(raw_input)
|
86
89
|
end
|
87
90
|
|
88
91
|
private
|
@@ -97,7 +100,7 @@ module Appstats
|
|
97
100
|
return nil_query if @query.nil?
|
98
101
|
current_query = fix_legacy_structures(@query)
|
99
102
|
|
100
|
-
parser =
|
103
|
+
parser = @@language_parser.dup
|
101
104
|
return nil_query unless parser.parse(current_query)
|
102
105
|
|
103
106
|
@operation = parser.results[:operation]
|
data/lib/appstats/version.rb
CHANGED
data/spec/entry_spec.rb
CHANGED
@@ -144,17 +144,17 @@ module Appstats
|
|
144
144
|
|
145
145
|
end
|
146
146
|
|
147
|
-
describe "#
|
147
|
+
describe "#create_from_logger_file" do
|
148
148
|
|
149
149
|
it "should handle nil" do
|
150
|
-
Entry.
|
150
|
+
Entry.create_from_logger_file(nil).should == false
|
151
151
|
Entry.count.should == @before_count
|
152
152
|
Entry.count.should == @before_count
|
153
153
|
end
|
154
154
|
|
155
155
|
it "should handle unknown files" do
|
156
156
|
File.exists?("should_not_exist.txt").should == false
|
157
|
-
Entry.
|
157
|
+
Entry.create_from_logger_file("should_not_exist.txt").should == false
|
158
158
|
Entry.count.should == @before_count
|
159
159
|
end
|
160
160
|
|
@@ -162,25 +162,25 @@ module Appstats
|
|
162
162
|
Appstats::Logger.entry("test_action")
|
163
163
|
Appstats::Logger.entry("another_test_action")
|
164
164
|
@before_count = Entry.count
|
165
|
-
Entry.
|
165
|
+
Entry.create_from_logger_file(Appstats::Logger.filename).should == true
|
166
166
|
Entry.count.should == @before_count + 2
|
167
167
|
Entry.last.action.should == "another_test_action"
|
168
168
|
end
|
169
169
|
|
170
170
|
end
|
171
171
|
|
172
|
-
describe "#
|
172
|
+
describe "#create_from_logger_string" do
|
173
173
|
|
174
174
|
it "should handle nil" do
|
175
|
-
Entry.
|
175
|
+
Entry.create_from_logger_string(nil).should == false
|
176
176
|
Entry.count.should == @before_count
|
177
177
|
|
178
|
-
Entry.
|
178
|
+
Entry.create_from_logger_string("").should == false
|
179
179
|
Entry.count.should == @before_count
|
180
180
|
end
|
181
181
|
|
182
182
|
it "should create an unknown for unknown entries" do
|
183
|
-
entry = Entry.
|
183
|
+
entry = Entry.create_from_logger_string("blah")
|
184
184
|
Entry.count.should == @before_count + 1
|
185
185
|
entry.action.should == "UNKNOWN_ACTION"
|
186
186
|
entry.raw_entry.should == "blah"
|
@@ -188,18 +188,18 @@ module Appstats
|
|
188
188
|
end
|
189
189
|
|
190
190
|
it "should understand an entry without contexts" do
|
191
|
-
entry = Entry.
|
191
|
+
entry = Entry.create_from_logger_string("0.8.1 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search")
|
192
192
|
Entry.count.should == @before_count + 1
|
193
193
|
entry.action.should == "address_search"
|
194
|
-
entry.raw_entry.should == "0.8.
|
194
|
+
entry.raw_entry.should == "0.8.1 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search"
|
195
195
|
entry.occurred_at.should == Time.parse("2010-09-21 23:15:20")
|
196
196
|
end
|
197
197
|
|
198
198
|
it "should understand contexts" do
|
199
|
-
entry = Entry.
|
199
|
+
entry = Entry.create_from_logger_string("0.8.1 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live")
|
200
200
|
Entry.count.should == @before_count + 1
|
201
201
|
entry.action.should == "address_filter"
|
202
|
-
entry.raw_entry.should == "0.8.
|
202
|
+
entry.raw_entry.should == "0.8.1 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live"
|
203
203
|
entry.occurred_at.should == Time.parse("2010-09-21 23:15:20")
|
204
204
|
entry.contexts.size.should == 2
|
205
205
|
entry.contexts[0].context_key = "app_name"
|
@@ -209,6 +209,24 @@ module Appstats
|
|
209
209
|
end
|
210
210
|
|
211
211
|
end
|
212
|
+
|
213
|
+
describe "#create_from_logger" do
|
214
|
+
|
215
|
+
it "should handle nil" do
|
216
|
+
Entry.create_from_logger(nil).should == false
|
217
|
+
Entry.count.should == @before_count
|
218
|
+
|
219
|
+
Entry.create_from_logger("").should == false
|
220
|
+
Entry.count.should == @before_count
|
221
|
+
end
|
222
|
+
|
223
|
+
it "should create using the logger entry_to_s" do
|
224
|
+
entry = Entry.create_from_logger("blah")
|
225
|
+
Entry.count.should == @before_count + 1
|
226
|
+
entry.action.should == "blah"
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
212
230
|
|
213
231
|
describe "#log_collector" do
|
214
232
|
|
data/spec/logger_spec.rb
CHANGED
@@ -115,7 +115,7 @@ module Appstats
|
|
115
115
|
|
116
116
|
it "should accept numbers" do
|
117
117
|
Appstats::Logger.entry(5, :blah => 6)
|
118
|
-
Appstats::Logger.raw_read.should == ["0.8.
|
118
|
+
Appstats::Logger.raw_read.should == ["0.8.1 setup[:,=,-n] 2010-09-21 23:15:20 action=5 : blah=6"]
|
119
119
|
end
|
120
120
|
|
121
121
|
end
|
@@ -124,7 +124,7 @@ module Appstats
|
|
124
124
|
|
125
125
|
it "should look similar to regular entry" do
|
126
126
|
Appstats::Logger.exception_entry(RuntimeError.new("blah"),:on => "login")
|
127
|
-
Appstats::Logger.raw_read.should == ["0.8.
|
127
|
+
Appstats::Logger.raw_read.should == ["0.8.1 setup[:,=,-n] 2010-09-21 23:15:20 action=appstats-exception : error=blah : on=login"]
|
128
128
|
end
|
129
129
|
|
130
130
|
end
|
@@ -141,29 +141,29 @@ module Appstats
|
|
141
141
|
|
142
142
|
it "should handle a statistics entry" do
|
143
143
|
expected = { :action => "address_search", :timestamp => "2010-09-21 23:15:20" }
|
144
|
-
actual = Appstats::Logger.entry_to_hash("0.8.
|
144
|
+
actual = Appstats::Logger.entry_to_hash("0.8.1 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search")
|
145
145
|
actual.should == expected
|
146
146
|
end
|
147
147
|
|
148
148
|
it "should handle contexts" do
|
149
149
|
expected = { :action => "address_filter", :timestamp => "2010-09-21 23:15:20", :server => "Live", :app_name => 'Market' }
|
150
|
-
actual = Appstats::Logger.entry_to_hash("0.8.
|
150
|
+
actual = Appstats::Logger.entry_to_hash("0.8.1 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live")
|
151
151
|
actual.should == expected
|
152
152
|
end
|
153
153
|
|
154
154
|
it "should handle actions with the delimiter (and change the delimiter)" do
|
155
155
|
expected = { :action => "address:=search-n", :timestamp => "2010-09-21 23:15:20" }
|
156
|
-
actual = Appstats::Logger.entry_to_hash("0.8.
|
156
|
+
actual = Appstats::Logger.entry_to_hash("0.8.1 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=search-n")
|
157
157
|
actual.should == expected
|
158
158
|
|
159
159
|
expected = { :action => "address::search==--n", :timestamp => "2010-09-21 23:15:20" }
|
160
|
-
actual = Appstats::Logger.entry_to_hash("0.8.
|
160
|
+
actual = Appstats::Logger.entry_to_hash("0.8.1 setup[:::,===,---n] 2010-09-21 23:15:20 action===address::search==--n")
|
161
161
|
actual.should == expected
|
162
162
|
end
|
163
163
|
|
164
164
|
it "should handle contexts with the delimiter (and change the delimiter)" do
|
165
165
|
expected = { :action => "address", :timestamp => "2010-09-21 23:15:20", :server => "market:eval=-n" }
|
166
|
-
actual = Appstats::Logger.entry_to_hash("0.8.
|
166
|
+
actual = Appstats::Logger.entry_to_hash("0.8.1 setup[::,==,--n] 2010-09-21 23:15:20 action==address :: server==market:eval=-n")
|
167
167
|
actual.should == expected
|
168
168
|
end
|
169
169
|
|
@@ -172,66 +172,66 @@ module Appstats
|
|
172
172
|
describe "#entry_to_s" do
|
173
173
|
|
174
174
|
it "should handle a statistics entry" do
|
175
|
-
expected = "0.8.
|
175
|
+
expected = "0.8.1 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search"
|
176
176
|
actual = Appstats::Logger.entry_to_s("address_search")
|
177
177
|
actual.should == expected
|
178
178
|
end
|
179
179
|
|
180
180
|
it "should handle numbers" do
|
181
|
-
expected = "0.8.
|
181
|
+
expected = "0.8.1 setup[:,=,-n] 2010-09-21 23:15:20 action=1 : note=2.2"
|
182
182
|
actual = Appstats::Logger.entry_to_s(1,:note => 2.2)
|
183
183
|
actual.should == expected
|
184
184
|
end
|
185
185
|
|
186
186
|
it "should handle default contexts" do
|
187
187
|
Appstats::Logger.default_contexts[:app_name] = "market"
|
188
|
-
expected = "0.8.
|
188
|
+
expected = "0.8.1 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search : app_name=market"
|
189
189
|
actual = Appstats::Logger.entry_to_s("address_search")
|
190
190
|
actual.should == expected
|
191
191
|
end
|
192
192
|
|
193
193
|
it "should handle contexts (and sort them by symbol)" do
|
194
|
-
expected = "0.8.
|
194
|
+
expected = "0.8.1 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live"
|
195
195
|
actual = Appstats::Logger.entry_to_s("address_filter", { :server => "Live", :app_name => 'Market' })
|
196
196
|
actual.should == expected
|
197
197
|
end
|
198
198
|
|
199
199
|
it "should handle actions with the delimiter (and change the delimiter)" do
|
200
|
-
expected = "0.8.
|
200
|
+
expected = "0.8.1 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=search-n"
|
201
201
|
actual = Appstats::Logger.entry_to_s("address:=search-n")
|
202
202
|
actual.should == expected
|
203
203
|
|
204
|
-
expected = "0.8.
|
204
|
+
expected = "0.8.1 setup[:::,===,---n] 2010-09-21 23:15:20 action===address::search==--n"
|
205
205
|
actual = Appstats::Logger.entry_to_s("address::search==--n")
|
206
206
|
actual.should == expected
|
207
207
|
end
|
208
208
|
|
209
209
|
it "should handle contexts with the delimiter (and change the delimiter)" do
|
210
|
-
expected = "0.8.
|
210
|
+
expected = "0.8.1 setup[::,==,--n] 2010-09-21 23:15:20 action==address :: server==market:eval=-n"
|
211
211
|
actual = Appstats::Logger.entry_to_s("address", :server => 'market:eval=-n')
|
212
212
|
actual.should == expected
|
213
213
|
end
|
214
214
|
|
215
215
|
it "should ignore spaces" do
|
216
|
-
expected = "0.8.
|
216
|
+
expected = "0.8.1 setup[:,=,-n] 2010-09-21 23:15:20 action=address search"
|
217
217
|
actual = Appstats::Logger.entry_to_s("address search")
|
218
218
|
actual.should == expected
|
219
219
|
end
|
220
220
|
|
221
221
|
it "should convert newlines in action" do
|
222
|
-
expected = "0.8.
|
222
|
+
expected = "0.8.1 setup[:,=,-n] 2010-09-21 23:15:20 action=address_-nsearch"
|
223
223
|
actual = Appstats::Logger.entry_to_s("address_\nsearch")
|
224
224
|
actual.should == expected
|
225
225
|
end
|
226
226
|
|
227
227
|
it "should convert newlines in context" do
|
228
|
-
expected = "0.8.
|
228
|
+
expected = "0.8.1 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search : blah=some-nlong-nstatement"
|
229
229
|
actual = Appstats::Logger.entry_to_s("address_search",:blah => "some\nlong\nstatement")
|
230
230
|
actual.should == expected
|
231
231
|
end
|
232
232
|
|
233
233
|
it "should convert newlines based on the delimiter" do
|
234
|
-
expected = "0.8.
|
234
|
+
expected = "0.8.1 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=--nsearch-n"
|
235
235
|
actual = Appstats::Logger.entry_to_s("address:=\nsearch-n")
|
236
236
|
actual.should == expected
|
237
237
|
end
|
data/spec/query_spec.rb
CHANGED
@@ -74,6 +74,24 @@ module Appstats
|
|
74
74
|
Appstats::Entry.create(:action => "myblahs")
|
75
75
|
query.run.count.should == 2
|
76
76
|
end
|
77
|
+
|
78
|
+
it "should perform the action search" do
|
79
|
+
Appstats::Entry.create_from_logger("myblahs", :one => "11", :two => "222")
|
80
|
+
Appstats::Entry.create_from_logger("myblahs", :one => "111", :two => "22")
|
81
|
+
|
82
|
+
query = Appstats::Query.new(:query => "# myblahs where one=11")
|
83
|
+
result = query.run
|
84
|
+
result.count.should == 1
|
85
|
+
|
86
|
+
query = Appstats::Query.new(:query => "# myblahs where one=anything")
|
87
|
+
query.run.count.should == 0
|
88
|
+
|
89
|
+
query = Appstats::Query.new(:query => "# myblahs where one=11 && two=22")
|
90
|
+
query.run.count.should == 0
|
91
|
+
|
92
|
+
query = Appstats::Query.new(:query => "# myblahs where one=11 || two=22")
|
93
|
+
query.run.count.should == 2
|
94
|
+
end
|
77
95
|
|
78
96
|
end
|
79
97
|
|
@@ -133,8 +151,8 @@ module Appstats
|
|
133
151
|
describe "where clause" do
|
134
152
|
|
135
153
|
it "should understand no quotes" do
|
136
|
-
expected_sql = "select count(*) from appstats_entries where action = 'login' and EXISTS (select * from appstats_contexts where appstats_entries.id = appstats_contexts.appstats_entry_id and ( (context_key='user' and context_value='aforward')))"
|
137
|
-
Appstats::Query.new(:query => "# logins where user=aforward").query_to_sql.should == expected_sql
|
154
|
+
expected_sql = "select count(*) from appstats_entries where action = 'login' and EXISTS (select * from appstats_contexts where appstats_entries.id = appstats_contexts.appstats_entry_id and ( (context_key = 'user' and context_value = 'aforward')))"
|
155
|
+
Appstats::Query.new(:query => "# logins where user = aforward").query_to_sql.should == expected_sql
|
138
156
|
end
|
139
157
|
end
|
140
158
|
end
|
@@ -166,26 +184,39 @@ module Appstats
|
|
166
184
|
end
|
167
185
|
|
168
186
|
it "should translate a = b into EXISTS query" do
|
169
|
-
Appstats::Query.contexts_filter_to_sql("a=b").should == "#{@template} (context_key='a' and context_value='b')))"
|
170
|
-
Appstats::Query.contexts_filter_to_sql(" a = b ").should == "#{@template} (context_key='a' and context_value='b')))"
|
187
|
+
Appstats::Query.contexts_filter_to_sql("a=b").should == "#{@template} (context_key = 'a' and context_value = 'b')))"
|
188
|
+
Appstats::Query.contexts_filter_to_sql(" a = b ").should == "#{@template} (context_key = 'a' and context_value = 'b')))"
|
171
189
|
end
|
172
190
|
|
173
191
|
it "should ignore single quotes" do
|
174
|
-
Appstats::Query.contexts_filter_to_sql("'aaa'='bbbb'").should == "#{@template} (context_key='aaa' and context_value='bbbb')))"
|
175
|
-
Appstats::Query.contexts_filter_to_sql(" 'aaa' = 'bbbb' ").should == "#{@template} (context_key='aaa' and context_value='bbbb')))"
|
192
|
+
Appstats::Query.contexts_filter_to_sql("'aaa'='bbbb'").should == "#{@template} (context_key = 'aaa' and context_value = 'bbbb')))"
|
193
|
+
Appstats::Query.contexts_filter_to_sql(" 'aaa' = 'bbbb' ").should == "#{@template} (context_key = 'aaa' and context_value = 'bbbb')))"
|
176
194
|
end
|
177
195
|
|
178
196
|
it "should allow for searching for all entries of a certain context" do
|
179
|
-
Appstats::Query.contexts_filter_to_sql("aaa").should == "#{@template} (context_key='aaa')))"
|
197
|
+
Appstats::Query.contexts_filter_to_sql("aaa").should == "#{@template} (context_key = 'aaa')))"
|
180
198
|
end
|
181
199
|
|
182
200
|
it "should allow for searching for several entries of a certain context" do
|
183
|
-
Appstats::Query.contexts_filter_to_sql("aaa || bbb").should == "#{@template} (context_key='aaa') or (context_key='bbb')))"
|
201
|
+
Appstats::Query.contexts_filter_to_sql("aaa || bbb").should == "#{@template} (context_key = 'aaa') or (context_key = 'bbb')))"
|
184
202
|
end
|
185
203
|
|
186
204
|
it "should allow complex queries" do
|
187
|
-
Appstats::Query.contexts_filter_to_sql("user='andrew' || user='aforward'").should == "#{@template} (context_key='user' and context_value='andrew') or (context_key='user' and context_value='aforward')))"
|
205
|
+
Appstats::Query.contexts_filter_to_sql("user='andrew' || user='aforward'").should == "#{@template} (context_key = 'user' and context_value = 'andrew') or (context_key = 'user' and context_value = 'aforward')))"
|
188
206
|
end
|
207
|
+
|
208
|
+
it "should support or" do
|
209
|
+
Appstats::Query.contexts_filter_to_sql("user='andrew' or user='aforward'").should == "#{@template} (context_key = 'user' and context_value = 'andrew') or (context_key = 'user' and context_value = 'aforward')))"
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should support like" do
|
213
|
+
Appstats::Query.contexts_filter_to_sql("user like '%andrew%'").should == "#{@template} (context_key = 'user' and context_value like '%andrew%')))"
|
214
|
+
end
|
215
|
+
|
216
|
+
it "should support and" do
|
217
|
+
Appstats::Query.contexts_filter_to_sql("user='andrew' and user='aforward'").should == "#{@template} (context_key = 'user' and context_value = 'andrew') and (context_key = 'user' and context_value = 'aforward')))"
|
218
|
+
end
|
219
|
+
|
189
220
|
|
190
221
|
it "should do simple 1 = 1 if invalid" do
|
191
222
|
Appstats::Query.contexts_filter_to_sql("").should == "1=1"
|
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: 61
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 1
|
10
|
+
version: 0.8.1
|
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-02-
|
18
|
+
date: 2011-02-17 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|