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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f2434f9ff05f83a8afa7b24dd8c6a1fdaf1a610
4
- data.tar.gz: bf2d50e27143639aa79f24955de772318e055206
3
+ metadata.gz: cfd544cf0526a07af17ba94586c727afbe6bb06f
4
+ data.tar.gz: 663ab59eb8eaf0191bf5df3d7a1070bce65a2ca9
5
5
  SHA512:
6
- metadata.gz: b873048397904601f22ed3357c37c1f405d59e45623c7c0d1ea81c16019a92eda289707afae038863275f987d206dffcb41dc9a2b96368954eeeaab42f6e3059
7
- data.tar.gz: 6b8118e920da08db389bd40708986c85256a604c3d6800a98a9c714885fb76719b6686bab421ae1f78f1679a00f6bd081c1895955104fe9c30d005ac89cdc661
6
+ metadata.gz: 1bc1ea71feed714e6651e21c427860463c7ca96ed32aa66b3ba8b157167c6b63f467a565e51f5e8b47c13ac02cf2c1a1f562dcbd358f09a437b9df5bca61d317
7
+ data.tar.gz: d60ba7feace7cd6a53663fb6264a93f1c8be05378a790aff36f7e667052eb95b12b011e667182b3fbbd2d22a44b41963f1fc7c51996a45965819e565668ed8a9
@@ -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
- exit 1
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(db, flags[:server_id])
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].to_i,
33
- :attacker_coords_y => attacker_coords[1].to_i,
34
- :attacker_coords_z => attacker_coords[2].to_i,
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].to_i,
39
- :victim_coords_y => victim_coords[1].to_i,
40
- :victim_coords_z => victim_coords[2].to_i,
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csgolytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Asmuth