Skip to content

Commit

Permalink
Added logging to AddInReplyToToTweets.
Browse files Browse the repository at this point in the history
  • Loading branch information
benhoskings committed Apr 13, 2010
1 parent aac1d5d commit 269f53f
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions db/migrate/20100412042558_add_in_reply_to_to_tweets.rb
Expand Up @@ -2,13 +2,20 @@ class AddInReplyToToTweets < ActiveRecord::Migration
def self.up
add_column :tweets, :in_reply_to_status_id, :integer
raise unless Tweet.replies.all? {|tweet|
in_reply_to = User.find_by_id(tweet.recipient_id).tweets.find(
:first,
:conditions => ["created_at < ?", tweet.created_at],
:order => "created_at DESC"
)
unless tweet.nil?
tweet.update_attribute :in_reply_to_status_id, in_reply_to.id
user = User.find_by_id(tweet.recipient_id)
if user.nil?
puts "Missing User<#{tweet.recipient_id}> for Tweet<#{tweet.id}> (#{tweet.tweet})"
else
in_reply_to = user.tweets.find(
:first,
:conditions => ["created_at < ?", tweet.created_at],
:order => "created_at DESC"
)
if tweet.nil?
puts "Missing in_reply_to tweet for User<#{tweet.recipient_id}>"
else
tweet.update_attribute :in_reply_to_status_id, in_reply_to.id
end
end
}
end
Expand Down

0 comments on commit 269f53f

Please sign in to comment.