<commit_before># frozen_string_literal: true

# Analytics Helper
module AnalyticsHelper
  def dates_before_past_time(account, transactions)
    transactions_from_past_time_to_now(account, transactions).keys.map { |date| l(date) }
  end

  def past_data(account, transactions)
    data = transactions_from_past_time_to_now(account, transactions).values
    data.each_with_index do |amount, index|
      if index.zero?
        data[index] += balance_before_past_time(account, transactions)
      else
        data[index] = data[index - 1] + amount
      end
    end
    data.map(&:to_f)
  end

  def balance_before_past_time(account, transactions)
    Account.find(account.id).initial_balance + transactions
                                               .where(account: account)<commit_msg>javascript don't know ruby's arrays :sweat_smile:<commit_after># frozen_string_literal: true

# Analytics Helper
module AnalyticsHelper
  def dates_before_past_time(account, transactions)
    transactions_from_past_time_to_now(account, transactions).keys.map { |date| l(date).as_json }.join(",")
  end

  def past_data(account, transactions)
    data = transactions_from_past_time_to_now(account, transactions).values
    data.each_with_index do |amount, index|
      if index.zero?
        data[index] += balance_before_past_time(account, transactions)
      else
        data[index] = data[index - 1] + amount
      end
    end
    data.map(&:to_f).join(",")
  end

  def balance_before_past_time(account, transactions)
    Account.find(account.id).initial_balance + transactions
                                               .where(account: account)
{'fraction_non_alphanumeric': 0.0907429963459196, 'fraction_numerical': 0.001218026796589525, 'mean_word_length': 3.3813333333333335, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5501712', 'n_tokens_mistral': 494, 'n_tokens_neox': 472, 'n_words': 97}