Module: UserIdentification

Defined in:
lib/log_analysis/user_identification.rb

Defined Under Namespace

Classes: Error

Class Method Summary collapse

Class Method Details

.execute(cleaned_data) ⇒ Object

Your code goes here…



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/log_analysis/user_identification.rb', line 8

def self.execute(cleaned_data)
  cleaned_data.each_with_object([]) do |record, arr|
    user = arr.detect { |i| i == record.user }
    if user
      user.records.push(record)
    else
      record.user.records = [record]
      arr << record.user
    end
  end
end