Skip to content
This repository

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

Open
esilverberg opened this Issue January 26, 2011 · 0 comments

1 participant

Eric Silverberg
Eric Silverberg

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
Something went wrong with that request. Please try again.