Add monthly visitors functionality #1

Merged
miguel456 merged 6 commits from feat/monthly-visitors into main 2024-05-20 13:31:19 +00:00
Showing only changes of commit f9db304c8f - Show all commits

View File

@ -46,6 +46,7 @@ def get_line_date(line)
match = line.match(pattern)[0]
else
raise StandardError("Invalid datetime data detected!")
# Tests would help find the bug...
end
# [12/Apr/2023:13:56:41 +0100] -> 12/Apr/2023:13:56:41 +0100 -> Apr/2023
Date.parse(match.gsub('[', '').gsub(']', '')).strftime('%b/%Y')
@ -159,7 +160,8 @@ top_client_errors.each do |ip, count|
end
monthly_visits.each do |ip, visits|
puts "IP #{ip} had the following visits:"
puts "------------ BY DATE ---------------"
puts("IP #{ip} had the following visits:")
visits.each do |date, count|
puts "#{date}: #{count} visits"
end