lib/tasks/migrate.rake
# usage: rake migrate:recipient RECIPIENT=<id>
rake migrate:recipient RECIPIENT=
rake migrate : recipient RECIPIENT =
def updates(user, recipient, proposals, funds)
    recipient.update_columns(user_id: user.id, migrated_on: Time.zone.now)
    return puts ': no Proposals' unless proposals.any?
    proposals.each do |proposal|
      if funds.nil?
        funds = Fund.joins(:themes).active.merge(proposal.themes).distinct
      end
      proposal.user_id = user.id
      proposal.generate_token(:access_token)
      proposal.migrated_on = Time.zone.now
      proposal.save(validate: false)
      if proposal.prevent_funder_verification?
        proposal.update_column(:private, proposal.updated_at)
      end
      proposal.assessments.destroy_all
      Assessment.analyse_and_update!(funds, proposal)
    end
    puts ": Proposal #{recipient.proposal.id}, User #{user.id}"
  end
def updates ( user , recipient , proposals , funds ) recipient . update_columns ( user_id : user . id , migrated_on : Time . zone . now ) return puts ': no Proposals' unless proposals . any? proposals . each do | proposal | if funds . nil? funds = Fund . joins ( :themes ) . active . merge ( proposal . themes ) . distinct end proposal . user_id = user . id proposal . generate_token ( :access_token ) proposal . migrated_on = Time . zone . now proposal . save ( validate : false ) if proposal . prevent_funder_verification? proposal . update_column ( :private , proposal . updated_at ) end proposal . assessments . destroy_all Assessment . analyse_and_update! ( funds , proposal ) end puts ": Proposal #{recipient.proposal.id}, User #{user.id}" end
usage: rake migrate:recipient RECIPIENT=<id>
usage : rake migrate : recipient RECIPIENT = <id >
user
<not_specific>
recipient
<not_specific>
proposals
<not_specific>
funds
<not_specific>