<commit_before>module PlaidRails
  class CreateAccountService
  
    # creates a new plaid_rails_account for each account the user has selected
    def self.call(account_params)
      account_params["account_ids"].each  do |id|
        # set Plaid::User
        user = Plaid.set_user(account_params["access_token"],['auth'])
        #find the account by account_id 
        account = user.accounts.select{|a| a.id==id}.first
        
        PlaidRails::Account.create!(
          access_token: account_params["access_token"], 
          plaid_type: account_params["type"],
          name: account.name,
          bank_name: account.meta["name"],
          number: account.meta["number"],
          owner_id: account_params["owner_id"],
          owner_type: account_params["owner_type"],
          available_balance: account.available_balance,
          current_balance: account.current_balance,
          plaid_id: id
        ) unless PlaidRails::Account.exists?(plaid_id: id)
      end
        
      PlaidRails::Account.where(owner_id: account_params["owner_id"], 
        owner_type: account_params["owner_type"])
    end
  end
end<commit_msg>use find instead of select <commit_after>module PlaidRails
  class CreateAccountService
  
    # creates a new plaid_rails_account for each account the user has selected
    def self.call(account_params)
      account_params["account_ids"].each  do |id|
        # set Plaid::User
        user = Plaid.set_user(account_params["access_token"],['auth'])
        #find the account by account_id 
        account = user.accounts.find{|a| a.id==id}
        
        PlaidRails::Account.create!(
          access_token: account_params["access_token"], 
          plaid_type: account_params["type"],
          name: account.name,
          bank_name: account.meta["name"],
          number: account.meta["number"],
          owner_id: account_params["owner_id"],
          owner_type: account_params["owner_type"],
          available_balance: account.available_balance,
          current_balance: account.current_balance,
          plaid_id: id
        ) unless PlaidRails::Account.exists?(plaid_id: id)
      end
        
      PlaidRails::Account.where(owner_id: account_params["owner_id"], 
        owner_type: account_params["owner_type"])
    end
  end
end
{'fraction_non_alphanumeric': 0.10295395308427455, 'fraction_numerical': 0.0, 'mean_word_length': 2.831946755407654, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4933318', 'n_tokens_mistral': 668, 'n_tokens_neox': 659, 'n_words': 132}