csgolytics 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/csgolytics-import +9 -2
- data/lib/csgolytics/feed_upload.rb +7 -1
- data/lib/csgolytics/log_parser.rb +14 -9
- 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: cfd544cf0526a07af17ba94586c727afbe6bb06f
|
4
|
+
data.tar.gz: 663ab59eb8eaf0191bf5df3d7a1070bce65a2ca9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bc1ea71feed714e6651e21c427860463c7ca96ed32aa66b3ba8b157167c6b63f467a565e51f5e8b47c13ac02cf2c1a1f562dcbd358f09a437b9df5bca61d317
|
7
|
+
data.tar.gz: d60ba7feace7cd6a53663fb6264a93f1c8be05378a790aff36f7e667052eb95b12b011e667182b3fbbd2d22a44b41963f1fc7c51996a45965819e565668ed8a9
|
data/bin/csgolytics-import
CHANGED
@@ -27,6 +27,10 @@ flag_parser = OptionParser.new do |opts|
|
|
27
27
|
flags[:server_id] = val
|
28
28
|
end
|
29
29
|
|
30
|
+
opts.on("--tee=PATH", "/path/to/output.log") do |val|
|
31
|
+
flags[:tee_file] = val
|
32
|
+
end
|
33
|
+
|
30
34
|
opts.on("--eventql_host=HOST", "EventQL host") do |val|
|
31
35
|
flags[:eventql_host] = val
|
32
36
|
end
|
@@ -64,7 +68,7 @@ end
|
|
64
68
|
|
65
69
|
unless File.directory?(flags[:logdir])
|
66
70
|
$stderr.puts "ERROR: #{flags[:logdir]} is not a directory"
|
67
|
-
|
71
|
+
exit 1
|
68
72
|
end
|
69
73
|
|
70
74
|
# init eventql client
|
@@ -84,7 +88,10 @@ schema_manager = CSGOLytics::SchemaManager.new(
|
|
84
88
|
schema_manager.migrate!
|
85
89
|
|
86
90
|
# start feed upload
|
87
|
-
feed_upload = CSGOLytics::FeedUpload.new(
|
91
|
+
feed_upload = CSGOLytics::FeedUpload.new(
|
92
|
+
db,
|
93
|
+
flags[:server_id],
|
94
|
+
flags[:tee_file])
|
88
95
|
|
89
96
|
# start log reader
|
90
97
|
log_reader = CSGOLytics::LogReader.new(flags[:logdir])
|
@@ -12,18 +12,24 @@ class CSGOLytics::FeedUpload
|
|
12
12
|
"assist" => "csgo_assists"
|
13
13
|
}
|
14
14
|
|
15
|
-
def initialize(db, server_id = nil)
|
15
|
+
def initialize(db, server_id = nil, tee_file = nil)
|
16
16
|
@db = db
|
17
17
|
@server_id = server_id
|
18
|
+
@tee_file = tee_file ? File.open(tee_file, "a+") : nil
|
18
19
|
@log_parser = CSGOLytics::LogParser.new
|
19
20
|
end
|
20
21
|
|
21
22
|
def insert_logline(logline, event_id = nil)
|
23
|
+
if @tee_file
|
24
|
+
@tee_file.write(logline + "\n")
|
25
|
+
end
|
26
|
+
|
22
27
|
ev = @log_parser.parse(logline)
|
23
28
|
unless ev
|
24
29
|
return
|
25
30
|
end
|
26
31
|
|
32
|
+
|
27
33
|
if event_id
|
28
34
|
ev[:event_id] = event_id
|
29
35
|
else
|
@@ -20,8 +20,8 @@ private
|
|
20
20
|
|
21
21
|
m = r.match(line)
|
22
22
|
if m
|
23
|
-
attacker_coords = m[:attacker_coords].split
|
24
|
-
victim_coords = m[:victim_coords].split
|
23
|
+
attacker_coords = m[:attacker_coords].split.map(&:to_i)
|
24
|
+
victim_coords = m[:victim_coords].split.map(&:to_i)
|
25
25
|
|
26
26
|
return {
|
27
27
|
:event => "frag",
|
@@ -29,18 +29,19 @@ private
|
|
29
29
|
:attacker_name => m[:attacker_name],
|
30
30
|
:attacker_steamid => m[:attacker_steamid],
|
31
31
|
:attacker_team => normalize_team(m[:attacker_team]),
|
32
|
-
:attacker_coords_x => attacker_coords[0]
|
33
|
-
:attacker_coords_y => attacker_coords[1]
|
34
|
-
:attacker_coords_z => attacker_coords[2]
|
32
|
+
:attacker_coords_x => attacker_coords[0],
|
33
|
+
:attacker_coords_y => attacker_coords[1],
|
34
|
+
:attacker_coords_z => attacker_coords[2],
|
35
35
|
:victim_name => m[:victim_name],
|
36
36
|
:victim_steamid => m[:victim_steamid],
|
37
37
|
:victim_team => normalize_team(m[:victim_team]),
|
38
|
-
:victim_coords_x => victim_coords[0]
|
39
|
-
:victim_coords_y => victim_coords[1]
|
40
|
-
:victim_coords_z => victim_coords[2]
|
38
|
+
:victim_coords_x => victim_coords[0],
|
39
|
+
:victim_coords_y => victim_coords[1],
|
40
|
+
:victim_coords_z => victim_coords[2],
|
41
41
|
:weapon => m[:weapon],
|
42
42
|
:headshot => !!m[:headshot],
|
43
|
-
:penetrated => !!m[:penetrated]
|
43
|
+
:penetrated => !!m[:penetrated],
|
44
|
+
:distance => euclidean_distance(attacker_coords, victim_coords)
|
44
45
|
}
|
45
46
|
end
|
46
47
|
end
|
@@ -76,4 +77,8 @@ private
|
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
80
|
+
def euclidean_distance(p1, p2)
|
81
|
+
Math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2 + (p1[2] - p2[2]) ** 2)
|
82
|
+
end
|
83
|
+
|
79
84
|
end
|