Created
April 16, 2013 20:55
-
-
Save andrius/5399575 to your computer and use it in GitHub Desktop.
Any way to optimize? To ensure that its working on MySQL, SQLITE, Postgre SQL?
This file contains 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
# Find next number to send call | |
def next_number | |
# first parse CDRs | |
Cdr.parse | |
# find number | |
sql_request = %{campaign_id = ? and | |
call_state = ? and | |
number_of_retries < ? and | |
(UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(updated_at)) <= ? | |
}.gsub(/\s+/," ").chomp.strip | |
CampaignNumber.where(sql_request, self.id, "idle", | |
amount_of_max_attempts, | |
minimal_timeout_between_retrials | |
).order("number_of_retries, updated_at").first | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment