Skip to content

Instantly share code, notes, and snippets.

@snarlysodboxer
Last active December 17, 2015 14:09
Show Gist options
  • Save snarlysodboxer/5622782 to your computer and use it in GitHub Desktop.
Save snarlysodboxer/5622782 to your computer and use it in GitHub Desktop.
This is just a spike for demonstration. It could be re-written better in many ways.
#!/usr/bin/env ruby
file_string = File.read('mail.redact.small')
line_array = Array.new
file_string.each_line { |line| line_array << line }
uid_array = Array.new
line_array.each do |line|
split_line = line.split
uid = split_line[3]
next unless uid.match /\:/
uid_array << uid
end
success_count, deferred_count, bounced_count, other_count = 0, 0, 0, 0
uid_array.each do |uid|
line_group = Array.new
line_array.each do |line|
if line =~ /#{uid}/
line_group << line
end
end
if line_group.join =~ /status=sent/
success_count = success_count + 1
elsif line_group.join =~ /status=deferred/
deferred_count = deferred_count + 1
elsif line_group.join =~ /status=bounced/
bounced_count = bounced_count + 1
else
other_count = other_count + 1
end
end
p "#{success_count} email sends succeeded"
p "#{deferred_count} email sends were deferred."
p "#{bounced_count} email sends were bounced."
p "#{other_count} email sends have other or no status codes."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment