Skip to content

Instantly share code, notes, and snippets.

@tomafro
Created July 5, 2011 07:34
Show Gist options
  • Save tomafro/1064411 to your computer and use it in GitHub Desktop.
Save tomafro/1064411 to your computer and use it in GitHub Desktop.
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
@tomafro
Copy link
Author

tomafro commented Jul 5, 2011

Need to take into account the end_time, and maybe BST vs UTC issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment