sms-logparser 0.16.1 → 0.16.2
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/mysql.rb +3 -3
- data/lib/sms-logparser/parser.rb +4 -2
- data/lib/sms-logparser/version.rb +1 -1
- data/spec/parser_spec.rb +2 -2
- 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: 18704246ac13ac9736ac6d02d4ca9333e3b9a905
|
4
|
+
data.tar.gz: 7df82e21b1edd971f32e756b29ca2e021235fa2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbe045ca18a2e7ee414431d64954296a746bf9fa7e313497ac7cf9f12ee26aef6e480bba4052af7243a5e95c8e1e6ef4087667f26f9015deb5d9cbef5ba0be38
|
7
|
+
data.tar.gz: 0c7582dcc4b3cac70cd0d0a2977cc58f6ad5c152c515caeeabe5374071b1ffa52938c27428601fbe65b444896ef9e81a1898770e1895a68807390ae94d7181e6
|
data/lib/sms-logparser/mysql.rb
CHANGED
@@ -3,10 +3,10 @@ module SmsLogparser
|
|
3
3
|
|
4
4
|
def initialize(options)
|
5
5
|
@options = options
|
6
|
-
@query_limit = options[:query_limit] || 5000
|
7
6
|
@client = client
|
8
|
-
@logger = SmsLogparser::Loggster.instance
|
9
7
|
@max_retries = 5
|
8
|
+
@query_limit = options[:query_limit] || 5000
|
9
|
+
@logger = SmsLogparser::Loggster.instance
|
10
10
|
end
|
11
11
|
|
12
12
|
def client
|
@@ -20,7 +20,7 @@ module SmsLogparser
|
|
20
20
|
|
21
21
|
def last_runs(results = 10)
|
22
22
|
runs = client.query(
|
23
|
-
"SELECT * FROM sms_logparser_runs ORDER BY id DESC LIMIT #{results ||
|
23
|
+
"SELECT * FROM sms_logparser_runs ORDER BY id DESC LIMIT #{results.to_i || 15}"
|
24
24
|
)
|
25
25
|
end
|
26
26
|
|
data/lib/sms-logparser/parser.rb
CHANGED
@@ -34,13 +34,15 @@ module SmsLogparser
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def extract_visit(log_message)
|
37
|
-
|
37
|
+
# only measure file bigger than 256K
|
38
|
+
size_limit = 256 * 1024
|
39
|
+
if log_message.status == 200 && log_message.bytes > size_limit &&
|
38
40
|
(log_message.file_extname =~ /\.(mp3|mp4|flv|f4v)/ || log_message.file == 'index.m3u8')
|
39
41
|
visit_data = log_message.account_info.merge(
|
40
42
|
type: "VISITORS_#{log_message.type}",
|
41
43
|
value: 1
|
42
44
|
)
|
43
|
-
logger.debug { "Counting visit: message
|
45
|
+
logger.debug { "Counting visit: message=\"#{log_message.message}\" data=#{visit_data}" }
|
44
46
|
else
|
45
47
|
logger.debug { "NOT counting VISITORS_#{log_message.type} for: #{log_message.message}" }
|
46
48
|
end
|
data/spec/parser_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe SmsLogparser::Parser do
|
4
4
|
|
5
5
|
it "count index.m3u8 with status 200 and user agent iPhone as mobile visit" do
|
6
|
-
message = '- - [22/Apr/2014:17:44:17 +0200] "GET /content/51/52/42701/index.m3u8 HTTP/1.1" 200
|
6
|
+
message = '- - [22/Apr/2014:17:44:17 +0200] "GET /content/51/52/42701/index.m3u8 HTTP/1.1" 200 319009 "-" "AppleCoreMedia/1.0.0.11D167 (iPhone; U; CPU OS 7_1 like Mac OS X; de_de)"'
|
7
7
|
data = SmsLogparser::Parser.extract_data_from_msg(message)
|
8
8
|
data[1][:customer_id].must_equal "51"
|
9
9
|
data[1][:author_id].must_equal "52"
|
@@ -13,7 +13,7 @@ describe SmsLogparser::Parser do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "count *.flv with status 200 and user agent Android as mobile visit" do
|
16
|
-
message = ' - - [22/Apr/2014:17:44:27 +0200] "GET /content/51/52/42709/simvid_1_40.flv HTTP/1.1" 200
|
16
|
+
message = ' - - [22/Apr/2014:17:44:27 +0200] "GET /content/51/52/42709/simvid_1_40.flv HTTP/1.1" 200 9625900 "http://blick.simplex.tv/NubesPlayer/index.html?cID=51&aID=52&pID=42709&autostart=false&themeColor=d6081c&embed=1&configUrl=http://f.blick.ch/resources/61786/ver1-0/js/xtendxIframeStatsSmartphone.js?adtechID=3522740&language=de&quality=40&hideHD=true&progressiveDownload=true" "Mozilla/5.0 (Linux; Android 4.4.2; C6903 Build/14.3.A.0.757) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36"'
|
17
17
|
data = SmsLogparser::Parser.extract_data_from_msg(message)
|
18
18
|
data[1][:customer_id].must_equal "51"
|
19
19
|
data[1][:author_id].must_equal "52"
|