Class: CSGOLytics::FeedUpload

Inherits:
Object
  • Object
show all
Defined in:
lib/csgolytics/feed_upload.rb

Constant Summary collapse

PARTITION_SIZE =
3600 * 24
EVENT_TABLE_MAP =
{
  "frag" => "csgo_frags",
  "assist" => "csgo_assists"
}

Instance Method Summary collapse

Constructor Details

#initialize(db, server_id = nil, tee_file = nil) ⇒ FeedUpload

Returns a new instance of FeedUpload.



15
16
17
18
19
20
# File 'lib/csgolytics/feed_upload.rb', line 15

def initialize(db, server_id = nil, tee_file = nil)
  @db = db
  @server_id = server_id
  @tee_file = tee_file ? File.open(tee_file, "a+") : nil
  @log_parser = CSGOLytics::LogParser.new
end

Instance Method Details

#insert_logline(logline, event_id = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/csgolytics/feed_upload.rb', line 22

def insert_logline(logline, event_id = nil)
  if @tee_file
    @tee_file.write(logline + "\n")
  end

  ev = @log_parser.parse(logline)
  unless ev
    return
  end


  if event_id
    ev[:event_id] = event_id
  else
    ev[:event_id] = Digest::SHA1.hexdigest logline
  end

  if @server_id
    ev[:server_id] = @server_id
  end

  upload_event(ev)
end