Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message sending logic is extremely inefficient for large #s of devices #24

Open
esilverberg opened this issue Jan 26, 2011 · 0 comments

Comments

@esilverberg
Copy link

This loop is brutally slow - you're looping through EVERY device looking for messages to send! The old version just looked for notifications with sent_at nil. That is much faster, and I ended up downgrading when I realized what was happening:

    APN::Connection.open_for_delivery({:cert => the_cert}) do |conn, sock|
      APN::Device.find_each(:conditions => conditions) do |dev|
        dev.unsent_notifications.each do |noty|
          conn.write(noty.message_for_sending)
          noty.sent_at = Time.now
          noty.save
        end
      end
    end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant