Skip to content

Instantly share code, notes, and snippets.

@BananaNeil
Created October 21, 2015 18:48
Show Gist options
  • Save BananaNeil/cdd65ae195b5dae25caf to your computer and use it in GitHub Desktop.
Save BananaNeil/cdd65ae195b5dae25caf to your computer and use it in GitHub Desktop.
Notificaiton performance script
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