<commit_before>class TransfersController < ApplicationController
  respond_to :html, :json
  
  def index
    @transfers = current_user.account_operations.paginate(:page => params[:page], :per_page => 16)
    respond_with @transfers
  end

  def new
    if params[:currency] == "EUR"
      @transfer = WireTransfer.new(:currency => "EUR")
      @transfer.build_bank_account
      fetch_bank_accounts
    else
      @transfer = Transfer.new(:currency => params[:currency] || "LRUSD")
    end
  end
  
  def show
    @transfer = current_user.account_operations.find(params[:id])
  end
  
  def create
    @transfer = Transfer.from_params(params[:transfer])
    @transfer.account = current_user
    
    if @transfer.is_a?(WireTransfer) && @transfer.bank_account
      @transfer.bank_account.user_id = current_user.id
    end
    
    Operation.transaction do
      o = Operation.create!
      o.account_operations << @transfer
      o.account_operations << AccountOperation.new do |ao|
        ao.amount = @transfer.amount && @transfer.amount.abs
        ao.currency = @transfer.currency
        ao.account = Account.storage_account_for(@transfer.currency)
      end
      
      raise(ActiveRecord::Rollback) unless o.save
    end

    unless @transfer.new_record?     
      redirect_to account_transfers_path,
        :notice => I18n.t("transfers.index.successful.#{@transfer.state}", :amount => @transfer.amount.abs, :currency => @transfer.currency)
    else
      fetch_bank_accounts
      render :action => :new
    end
  end
  
  
  protected
  
    def fetch_bank_accounts
      @bank_accounts = current_user.bank_accounts.map { |ba| [ba.iban, ba.id] }
    end
end<commit_msg>JSON output after transfer<commit_after>class TransfersController < ApplicationController
  respond_to :html, :json
  
  def index
    @transfers = current_user.account_operations.paginate(:page => params[:page], :per_page => 16)
    respond_with @transfers
  end

  def new
    if params[:currency] == "EUR"
      @transfer = WireTransfer.new(:currency => "EUR")
      @transfer.build_bank_account
      fetch_bank_accounts
    else
      @transfer = Transfer.new(:currency => params[:currency] || "LRUSD")
    end
  end
  
  def show
    @transfer = current_user.account_operations.find(params[:id])
    respond_with @transfer
  end
  
  def create
    @transfer = Transfer.from_params(params[:transfer])
    @transfer.account = current_user
    
    if @transfer.is_a?(WireTransfer) && @transfer.bank_account
      @transfer.bank_account.user_id = current_user.id
    end
    
    Operation.transaction do
      o = Operation.create!
      o.account_operations << @transfer
      o.account_operations << AccountOperation.new do |ao|
        ao.amount = @transfer.amount && @transfer.amount.abs
        ao.currency = @transfer.currency
        ao.account = Account.storage_account_for(@transfer.currency)
      end
      
      raise(ActiveRecord::Rollback) unless o.save
    end

    unless @transfer.new_record?
      respond_with @transfer do |format|
        format.html do
          redirect_to account_transfers_path,
            :notice => I18n.t("transfers.index.successful.#{@transfer.state}", :amount => @transfer.amount.abs, :currency => @transfer.currency)
        end
      end
    else
      fetch_bank_accounts
      render :action => :new
    end
  end
  
  
  protected
  
    def fetch_bank_accounts
      @bank_accounts = current_user.bank_accounts.map { |ba| [ba.iban, ba.id] }
    end
end
{'fraction_non_alphanumeric': 0.1050672774119668, 'fraction_numerical': 0.002290294875465216, 'mean_word_length': 2.9704545454545452, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5202477', 'n_tokens_mistral': 1065, 'n_tokens_neox': 1052, 'n_words': 210}