Created
July 5, 2011 07:34
-
-
Save tomafro/1064411 to your computer and use it in GitHub Desktop.
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
start_time = Time.utc(2011, 07, 04, 12, 18) | |
mps = MessagePart.where(:timestamp.gt => start_time).collect do |mp| | |
account_msisdn = Subscriber.find(mp.subscriber_id).account.msisdn | |
attributes = mp.attributes.slice("content", "total_parts", "message_id", "part", "contact_msisdn", "sent") | |
%{ | |
MessagePart.create!(#{attributes.inspect}.merge( | |
:subscriber_id => Account.find_by_msisdn(#{account_msisdn.inspect}).subscriber.id, | |
:timestamp => Time.parse(#{mp.timestamp.to_s.inspect}) | |
)) | |
} | |
end | |
messages = Resque.peek(Jobs::PduFailedMessage.queue, 213, 66) | |
ims = messages.collect do |m| | |
%{ | |
Resque.enqueue(Jobs::IncomingMessage, #{m["args"][0].inspect}) | |
} | |
end | |
ms = Message.where(:timestamp.gt => start_time).collect do |m| | |
account_msisdn = m.subscriber.msisdn | |
attributes = m.attributes.slice("sent", "contact_msisdn", "content") | |
%{ | |
Account.unscoped.find_by_msisdn(#{account_msisdn.inspect}).import_message!(#{attributes.inspect}.merge( | |
:timestamp => Time.parse(#{m.timestamp.to_s.inspect}) | |
)) | |
} | |
end | |
puts mps + ims + ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Need to take into account the end_time, and maybe BST vs UTC issues