Created
October 21, 2015 18:48
-
-
Save BananaNeil/cdd65ae195b5dae25caf to your computer and use it in GitHub Desktop.
Notificaiton performance script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CSV.open('/tmp/notifications.csv', 'w') do |csv| | |
UserNotification.select("distinct type").map(&:type).each do |type| | |
total = UserNotification.where(type: type, send_state: 'sent').group(:message).count | |
opened = UserNotification.where(type: type, send_state: 'sent').where(open_state: 'open').group(:message).count | |
csv << ["Type", "Sent", "Opened", "Message", "First Date Sent"] | |
c = h.keys.count | |
total.keys.each do |message| | |
print "\r#{c-=1} " | |
csv << [type.split('::').last, total[message], opened[message] || 0, message, n.created_at] | |
end | |
end | |
end | |
================================================================================================== | |
ssh deployment "scp worker01:/tmp/notifications.csv /tmp/notifications.csv";scp deployment:/tmp/notifications.csv ~/Downloads/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment