<commit_before>class Transaction < ActiveRecord::Base
  belongs_to :payer, class_name: :Account, foreign_key: :id
  belongs_to :receiver, class_name: :Account, foreign_key: :id2
  belongs_to :administrator, class_name: :Account, foreign_key: :admin

  def self.log(account, bank, amount, comment: nil, admin: nil)
    now = Time.current
    comment ||= ''
    amount = (amount * 100).ceil # Screwing the customers
    transaction do
      account.balance = account.balance - amount
      account.turnover = account.turnover + amount if amount > 0
      bank.balance = bank.balance + amount
      bank.turnover = bank.turnover - amount if amount < 0
      create(id: account.id, id2: bank.id, price: amount, comment: comment, admin: admin.try(:id), date: now)
      create(id: bank.id, id2: account.id, price: -amount, comment: comment, admin: admin.try(:id), date: now)
      account.save
      bank.save
    end<commit_msg>Fix transaction logging<commit_after>class Transaction < ActiveRecord::Base
  belongs_to :payer, class_name: :Account, foreign_key: :id
  belongs_to :receiver, class_name: :Account, foreign_key: :id2
  belongs_to :administrator, class_name: :Account, foreign_key: :admin

  def self.log(account, bank, amount, comment: nil, admin: nil)
    now = Time.current
    comment ||= ''
    amount = (amount * 100).ceil # Screwing the customers
    transaction do
      account.balance = account.balance - amount
      account.turnover = account.turnover + amount if amount > 0
      bank.balance = bank.balance + amount
      bank.turnover = bank.turnover - amount if amount < 0
      create(id: account.id, id2: bank.id, price: -amount, comment: comment, admin: admin.try(:id), date: now)
      create(id: bank.id, id2: account.id, price: amount, comment: comment, admin: admin.try(:id), date: now)
      account.save
      bank.save
    end
{'fraction_non_alphanumeric': 0.116254036598493, 'fraction_numerical': 0.008611410118406888, 'mean_word_length': 3.6129032258064515, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '4790721', 'n_tokens_mistral': 573, 'n_tokens_neox': 566, 'n_words': 171}