Module: Transformation
- Defined in:
- lib/log_analysis/transformation.rb
Defined Under Namespace
Classes: Error
Class Method Summary collapse
-
.execute(identified_session) ⇒ Object
Your code goes here…
Class Method Details
.execute(identified_session) ⇒ Object
Your code goes here…
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/log_analysis/transformation.rb', line 9 def self.execute(identified_session) map_uri = [] transform = identified_session.each_with_object({}) do |v, hash| uries = v.records.map(&:uri) uries.each { |i| map_uri.push(i) unless map_uri.include?(i) } if hash.key?(v.user.host.to_s) uries.size == 1 ? hash[v.user.host.to_s] += v.records.map { |i| map_uri.index(i.uri) } : hash[v.user.host.to_s].push(v.records.map { |i| map_uri.index(i.uri) }) else hash.merge!(v.user.host.to_s => v.records.map { |i| map_uri.index(i.uri) }) end end File.open(LogAnalysis::MAP_URI_FILE_PATH, 'w+') { |f| f.write(map_uri.join(' ')) } transform end |