Last active
August 29, 2015 14:06
-
-
Save niallsmart/8f57bab4cc6da2659c86 to your computer and use it in GitHub Desktop.
Set last comment/last proposal on restored deals
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
ActiveRecord::Base.logger = Logger.new(STDERR) | |
ActiveRecord::Base.logger.level = Logger::DEBUG | |
deal_ids = [11929, 11930, 11928, 11927, 12166, 11933, 11934, 12369, 11984, 11931, 11924, 11922, 11921, 11920, 11919, 11926, 11923]; | |
Deal.where(id: deal_ids).find_each do |deal| | |
deal.update_column :last_comment_id, deal.comments.last.try(:id) | |
deal.update_column :last_proposal_id, deal.proposals.last.try(:id) | |
deal.update_column :last_dying_update_id, deal.updates.where(type: 'DealDyingUpdate').last.try(:id) | |
deal.update_column :last_executed_update_id, deal.updates.where(type: 'DealExecutedUpdate').last.try(:id) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment