class SidekiqLogAnalyser::Collection

Attributes

collection[R]
end_collection[R]
start_collection[R]

Public Class Methods

new(lines) click to toggle source
# File lib/sidekiq_log_analyser/collection.rb, line 6
def initialize(lines)
  @from_date = 1.month.ago
  populate(lines)
end

Public Instance Methods

populate(lines) click to toggle source
# File lib/sidekiq_log_analyser/collection.rb, line 11
def populate(lines)
  @collection = []
  lines.each do |line|
    row = Row.new(line)
    if row.valid?
      metadata = row.metadata
      @collection << metadata if in_range?(metadata[:datetime])
    end
  end
  @start_collection ||= collection(:start).group_by{|metadata| metadata[:worker]}
  @end_collection   ||= collection(:end).group_by{|metadata| metadata[:worker]}
  @collection         = []
end

Private Instance Methods

in_range?(datetime) click to toggle source
# File lib/sidekiq_log_analyser/collection.rb, line 27
def in_range?(datetime)
  return false if datetime.blank?

  @from_date < datetime
end