Class: Nfcollector::WeblogPartition

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

Instance Attribute Summary

Attributes inherited from Partition

#account_id, #headers, #partition_id, #rows

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Partition

#add_row, #file_name, get_partitioner, #initialize, #table_name

Constructor Details

This class inherits a constructor from Nfcollector::Partition

Class Method Details

.partition_id(value) ⇒ Object

Calculates the ID for this partition Think of it as a statistical ‘bin’

In this case we take the date from a timestamp



10
11
12
# File 'lib/nfcollector/weblog_partition.rb', line 10

def self.partition_id(value)
  Date.new(value.year, value.month, value.mday)
end

Instance Method Details

#keysObject



14
15
16
# File 'lib/nfcollector/weblog_partition.rb', line 14

def keys
  { account_id: , created_at: range_from_date }
end

#range_from_dateObject



18
19
20
21
22
23
24
# File 'lib/nfcollector/weblog_partition.rb', line 18

def range_from_date
  date       = partition_id
  next_date  = partition_id.next
  start_time = Time.utc(date.year, date.month, date.mday)
  end_time   = Time.utc(next_date.year, next_date.month, next_date.mday)
  start_time...end_time
end