sms-logparser 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sms-logparser/cli.rb +3 -3
- data/lib/sms-logparser/mysql.rb +21 -10
- data/lib/sms-logparser/version.rb +1 -1
- data/spec/api_spec.rb +10 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e27a12723425509ba68cdaf5ff40b2e8cf0c8f7
|
4
|
+
data.tar.gz: 1f28ec67759effb560f95eb20dd9746f3c6c1438
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf90a38a56e49ed5b20fb8befcefd91b0b898d165287cdecbbbca99d471b4247dface8454799606ca2861001dc8f7d99fabe10aa9b03649afd104ffd6c8c9c89
|
7
|
+
data.tar.gz: 0020bd4587d6588753694888c0dc84b4fa6d053b71c1b8dabd0ac959bb778f9d5b28456f94b9e0ec4f8f70553a8df3d3b806697871fd536429a54c720cf9c6a8
|
data/lib/sms-logparser/cli.rb
CHANGED
@@ -81,7 +81,7 @@ module SmsLogparser
|
|
81
81
|
if data
|
82
82
|
requests = api.send(data)
|
83
83
|
state[:match_count] += 1
|
84
|
-
verbose_parser_output(data, requests, entry) if options[:verbose]
|
84
|
+
verbose_parser_output(data, requests, entry['ID']) if options[:verbose]
|
85
85
|
end
|
86
86
|
end
|
87
87
|
state[:last_event_id] = entry['ID']
|
@@ -155,9 +155,9 @@ module SmsLogparser
|
|
155
155
|
end
|
156
156
|
|
157
157
|
no_commands do
|
158
|
-
def verbose_parser_output(data, requests,
|
158
|
+
def verbose_parser_output(data, requests, entry_id)
|
159
159
|
say "ID:\t", :cyan
|
160
|
-
say
|
160
|
+
say entry_id
|
161
161
|
say "URL:\t", :cyan
|
162
162
|
say requests.map {|req| "#{req[:url]}#{req[:uri]} (Status: #{req[:status] || 'n/a'})"}.join("\n\t")
|
163
163
|
say "Data:\t", :cyan
|
data/lib/sms-logparser/mysql.rb
CHANGED
@@ -78,15 +78,12 @@ module SmsLogparser
|
|
78
78
|
|
79
79
|
def get_entries(options={})
|
80
80
|
last_id = options[:last_id] || get_last_parse_id
|
81
|
-
|
82
|
-
max_id = last_id + options[:limit] + 1
|
83
|
-
else
|
84
|
-
max_id = get_last_event_id
|
85
|
-
end
|
81
|
+
max_id, query_limit = get_query_limits(last_id, options[:limit])
|
86
82
|
while last_id < max_id
|
87
|
-
entries = select_entries(last_id)
|
83
|
+
entries = select_entries(last_id, query_limit)
|
88
84
|
yield entries
|
89
|
-
|
85
|
+
entries = entries.to_a
|
86
|
+
last_id = entries.size > 0 ? entries[-1]['ID'] : max_id
|
90
87
|
end
|
91
88
|
end
|
92
89
|
|
@@ -99,11 +96,25 @@ module SmsLogparser
|
|
99
96
|
|
100
97
|
private
|
101
98
|
|
102
|
-
def
|
103
|
-
|
99
|
+
def get_query_limits(last_id, user_limit = nil)
|
100
|
+
if user_limit
|
101
|
+
max_id = last_id + user_limit
|
102
|
+
if @query_limit > user_limit
|
103
|
+
query_limit = user_limit
|
104
|
+
end
|
105
|
+
else
|
106
|
+
max_id = get_last_event_id
|
107
|
+
end
|
108
|
+
[max_id, query_limit || @query_limit]
|
109
|
+
end
|
110
|
+
|
111
|
+
def select_entries(offset, max_entries = @query_limit)
|
112
|
+
client.query(
|
113
|
+
"SELECT * FROM SystemEvents\
|
104
114
|
WHERE `FromHost` like '#{@host_filter}'\
|
105
115
|
ORDER BY ID ASC\
|
106
|
-
LIMIT #{
|
116
|
+
LIMIT #{offset},#{max_entries};"
|
117
|
+
)
|
107
118
|
end
|
108
119
|
|
109
120
|
def get_last_event_id
|
data/spec/api_spec.rb
CHANGED
@@ -20,10 +20,10 @@ describe SmsLogparser::Api do
|
|
20
20
|
:traffic_type => 'TRAFFIC_WEBCAST',
|
21
21
|
:visitor_type => 'VISITORS_WEBCAST'
|
22
22
|
}
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
requests = @api.send(data)
|
24
|
+
requests.size.must_equal 2
|
25
|
+
requests[0][:uri].must_match /\/1\/2\/3\/TRAFFIC_WEBCAST\/128$/
|
26
|
+
requests[1][:uri].must_match /\/1\/2\/3\/VISITORS_WEBCAST\/1$/
|
27
27
|
end
|
28
28
|
|
29
29
|
it "does not send traffic for m3u8 files" do
|
@@ -37,9 +37,9 @@ describe SmsLogparser::Api do
|
|
37
37
|
:traffic_type => 'TRAFFIC_MOBILE',
|
38
38
|
:visitor_type => 'VISITORS_MOBILE'
|
39
39
|
}
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
requests = @api.send(data)
|
41
|
+
requests.size.must_equal 1
|
42
|
+
requests[0][:uri].must_match /\/100\/200\/300\/VISITORS_MOBILE\/1$/
|
43
43
|
end
|
44
44
|
|
45
45
|
it "does not send visitor info if no visitor_type" do
|
@@ -52,9 +52,9 @@ describe SmsLogparser::Api do
|
|
52
52
|
:user_agent => 'Mozilla/5.0 (Android; Mobile; rv:13.0) Gecko/13.0 Firefox/13.0',
|
53
53
|
:traffic_type => 'TRAFFIC_MOBILE',
|
54
54
|
}
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
requests = @api.send(data)
|
56
|
+
requests.size.must_equal 1
|
57
|
+
requests[0][:uri].must_match /\/101\/202\/303\/TRAFFIC_MOBILE\/48$/
|
58
58
|
end
|
59
59
|
|
60
60
|
end
|