<commit_before>require 'debugger'

namespace :bitfication do
  desc "Update exchange statistics"
  task :stats => :environment do
    
    
    #if stat doesn't exist, create it
    if Stats.count < 1
      ns = Stats.new
      ns.volume = 0
      ns.phigh = 0
      ns.plow = 0
      ns.pwavg = 0
      ns.save!
    end
    
    
    puts Stats.count
    
    currency = "brl"
    
    @ticker = {
      :high => Trade.with_currency(currency).since_0h.maximum(:ppc),
      :low => Trade.with_currency(currency).since_0h.minimum(:ppc),
      :volume => (Trade.with_currency(currency).since_0h.sum(:traded_btc) || 0),
      :last_trade => Trade.with_currency(currency).count.zero? ? 0 : {
        :at => Trade.with_currency(currency).plottable(currency).last.created_at.to_i,
        :price => Trade.with_currency(currency).plottable(currency).last.ppc
      }
    }
    
    @ticker[:high] = @ticker[:high]==nil ? 0 : @ticker[:high]<commit_msg>Infobar - High/Low as last trades<commit_after>require 'debugger'

namespace :bitfication do
  desc "Update exchange statistics"
  task :stats => :environment do
    
    
    #if stat doesn't exist, create it
    if Stats.count < 1
      ns = Stats.new
      ns.volume = 0
      ns.phigh = 0
      ns.plow = 0
      ns.pwavg = 0
      ns.save!
    end
    
    
    puts Stats.count
    
    currency = "brl"
    
    @ticker = {
      :high => Trade.with_currency(currency).last.maximum(:ppc),
      :low => Trade.with_currency(currency).last.minimum(:ppc),
      :volume => (Trade.with_currency(currency).since_0h.sum(:traded_btc) || 0),
      :last_trade => Trade.with_currency(currency).count.zero? ? 0 : {
        :at => Trade.with_currency(currency).plottable(currency).last.created_at.to_i,
        :price => Trade.with_currency(currency).plottable(currency).last.ppc
      }
    }
    
    @ticker[:high] = @ticker[:high]==nil ? 0 : @ticker[:high]
{'fraction_non_alphanumeric': 0.13894736842105262, 'fraction_numerical': 0.010526315789473684, 'mean_word_length': 2.546641791044776, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '2820576', 'n_tokens_mistral': 680, 'n_tokens_neox': 649, 'n_words': 117}