log_analysis 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4da3bc937c35f605da6c99b694104dab09af74be0f373a2537c990923e1c9bcb
4
- data.tar.gz: b9ab4de5844da665fd5ac587c0404530971113208c82847f5b3130ad02d26764
3
+ metadata.gz: 90d23db656f54440f9e7b66a4bb83d6eb3ee82f6d15095cb61f1124c90843b81
4
+ data.tar.gz: 47b6770970bbf2fe5ecb8a9fee5164e29399d5f28c45373e70fac468c3cf3650
5
5
  SHA512:
6
- metadata.gz: d477e49633b472c87f065317a107ab8423a3f0d2f6f7549bb3a35b36f4780f8a17bf58b58589fe0397329abc3e9a1181dd8bd099d0972808a3306be24fa7d7b6
7
- data.tar.gz: cc4756d9bc8ed7199b9f9f1e67d3a0245dd7e2d511fe82b517eff5f0cc00bce89a84b7bd76842eeebd2ad3a354c0279e437dfee8e4973f3d29a66c194449e649
6
+ metadata.gz: eba66ff44c7a018b307af73b9c1b2146c1e55f4a29381864759a3d80a030267911c2e101f03c366fa75d30b4e4bff3840f216d3966f40051756bcf2c7d76d0b6
7
+ data.tar.gz: 9d1bc9317752d18d721345fa6af4f9161e5c2a2b3843177f64dc2a19095618e5897da585f7b1c1ef1a2d6f8180ec164303cc7fb3bbd34443258564b3561c7b4a
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- log_analysis (0.1.3)
4
+ log_analysis (0.1.4)
5
5
  activesupport (~> 6.0.3.1)
6
6
  useragent (~> 0.16.10)
7
7
 
@@ -43,6 +43,8 @@ class LogAnalysis
43
43
  end
44
44
 
45
45
  def move_data
46
+ return unless File.directory?('/home/app/data/waazabag/')
47
+
46
48
  system('mv', "transform_data_#{Time.now.strftime('%Y%m%d')}.txt", '/home/app/data/waazabag/')
47
49
  system('mv', "output_#{Time.now.strftime('%Y%m%d')}.txt", '/home/app/data/waazabag/')
48
50
  system('mv', "map_uri_#{Time.now.strftime('%Y%m%d')}.txt", '/home/app/data/waazabag/')
@@ -13,17 +13,19 @@ module PreProcess
13
13
  CONVERT_RECORD = { 'nginx' => 'convert_nginx_logs', 'apache' => 'convert_apache_logs', 'default' => 'to_records' }.freeze
14
14
 
15
15
  def self.input(file_path, type)
16
- @users = []
16
+ @users = []
17
+ text_file = File.readlines(file_path)
17
18
 
18
- File.readlines(file_path).each_with_object([]).with_index do |(line, arr), i|
19
+ text_file.each_with_object([]).with_index do |(line, arr), i|
19
20
  preprocessed_log = type.nil? ? line.gsub(/[\t]/i, ' ').chomp! : line
20
21
  record_params = send(CONVERT_RECORD[type.nil? ? 'nginx' : type], preprocessed_log)
21
22
  record = Record.new(record_params) if record_params && preprocessed_log
22
- record = yield(record) if block_given?
23
+ record = yield(record) if block_given? && record
23
24
 
24
25
  arr.push(record) if record && record.status_200? && record.method_get? && record.uri_without_data && !record.robot?
25
26
 
26
- puts arr.size
27
+ system('clear')
28
+ puts "#{((i.to_f / text_file.size) * 100).round}/100"
27
29
  end
28
30
  end
29
31
 
@@ -1,3 +1,3 @@
1
1
  class LogAnalysis
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log_analysis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Tran