<commit_before>class BlockchainHandlerJob < ApplicationJob
  queue_as :default

  def perform(blockchaintransaction)
    if !blockchaintransaction.confirmed_at.nil?
      return true
    elsif blockchaintransaction.submitted_at.nil?
      api = BidappApi.new
      if blockchaintransaction.transaction_type_id == 1
        transaction = api.mint(blockchaintransaction.account.address, blockchaintransaction.value)
      elsif blockchaintransaction.transaction_type_id == 2
        transaction = api.spend(blockchaintransaction.account.address, blockchaintransaction.value)
      elsif blockchaintransaction.transaction_type_id == 3
        transaction = api.transfer(blockchaintransaction.account.address, blockchaintransaction.recipient.address, blockchaintransaction.value)
      end
      
      if transaction['data']
        et = Ethtransaction.find_by(txaddress: transaction['data'])
        blockchaintransaction.ethtransaction = et
        blockchaintransaction.activity.ethtransaction = et
        blockchaintransaction.submitted_at = Time.current
        blockchaintransaction.save
        blockchaintransaction.activity.save
      else
        logger.warn('errors: ' + transaction.inspect)
      end
      
    end
  end
end<commit_msg>wait for ethtransaction to appear<commit_after>class BlockchainHandlerJob < ApplicationJob
  queue_as :default

  def perform(blockchaintransaction)
    if !blockchaintransaction.confirmed_at.nil?
      return true
    elsif blockchaintransaction.submitted_at.nil?
      api = BidappApi.new
      if blockchaintransaction.transaction_type_id == 1
        transaction = api.mint(blockchaintransaction.account.address, blockchaintransaction.value)
      elsif blockchaintransaction.transaction_type_id == 2
        transaction = api.spend(blockchaintransaction.account.address, blockchaintransaction.value)
      elsif blockchaintransaction.transaction_type_id == 3
        transaction = api.transfer(blockchaintransaction.account.address, blockchaintransaction.recipient.address, blockchaintransaction.value)
      end
      sleep 4
      if transaction['data']
        et = Ethtransaction.find_by(txaddress: transaction['data'])
        blockchaintransaction.ethtransaction = et
        blockchaintransaction.activity.ethtransaction = et
        blockchaintransaction.submitted_at = Time.current
        blockchaintransaction.save
        blockchaintransaction.activity.save
      else
        logger.warn('errors: ' + transaction.inspect)
      end
      
    end
  end
end
{'fraction_non_alphanumeric': 0.06664022213407378, 'fraction_numerical': 0.002776675922253074, 'mean_word_length': 3.6531365313653135, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4420559', 'n_tokens_mistral': 654, 'n_tokens_neox': 709, 'n_words': 115}