Class: Nfcollector::Categoriser

Inherits:
Object
  • Object
show all
Defined in:
lib/nfcollector/categoriser.rb

Defined Under Namespace

Classes: Entry

Instance Method Summary collapse

Constructor Details

#initialize(account_id) ⇒ Categoriser

Returns a new instance of Categoriser.



21
22
23
24
25
# File 'lib/nfcollector/categoriser.rb', line 21

def initialize()
  @account_id = 
  @domains    = {}
  @hosts      = {}
end

Instance Method Details

#commit!Object



37
38
39
40
41
# File 'lib/nfcollector/categoriser.rb', line 37

def commit!
  # TODO: This feels a bit clunky...
  Configuration.categorisation_domains_committer.commit(@account_id, @domains)
  Configuration.categorisation_hosts_committer.commit(@account_id, @hosts)
end

#perform(mapped_row, indicies) ⇒ Object

def perform(domain, host, last_seen)



28
29
30
31
32
33
34
35
# File 'lib/nfcollector/categoriser.rb', line 28

def perform(mapped_row, indicies)
  domain, host, last_seen = mapped_row.values_at(*indicies)
  @domains[domain] ||= Entry.new
  @hosts[host]     ||= Entry.new
  # TODO: This is doing TWO lookups
  @domains[domain].update(last_seen, mapped_row.category_ids)
  @hosts[host].update(last_seen, mapped_row.category_ids)
end