Sha256: 85bd02da34c1dab6e0c44c693c7b7eb32da8f0200a77a3af0e445db84bf54f71

Contents?: true

Size: 822 Bytes

Versions: 11

Compression:

Stored size: 822 Bytes

Contents

namespace :report do
  desc 'Run the possibility report.'
  task :possibilities, [:pool_id] => [:environment] do |t, args|
    $stdout.sync = true
    pool_id = args[:pool_id].to_i
    tournament_pool = Pool.find(pool_id).pool
    puts "Calculating stats for pool with #{tournament_pool.tournament_entry.picks.number_of_outcomes} possible outcomes ..."
    stats = tournament_pool.possibility_stats do |percentage, remaining|
      hashes = '#' * (percentage.to_i/5) + '>'
      print "\rCalculating: %3d%% +#{hashes.ljust(20, '-')}+ %5d seconds remaining" % [percentage.to_i, remaining]
    end
    puts
    stats_yaml_file = File.join(RAILS_ROOT, 'db', "stats_#{pool_id}.yml")
    bytes = File.open(stats_yaml_file, "w") {|f| f.write YAML.dump(stats)}
    puts "Wrote #{bytes} bytes to #{stats_yaml_file} ..."
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
tournament-4.0.2 webgui/lib/tasks/possibility.rake
tournament-4.0.0 webgui/lib/tasks/possibility.rake
tournament-3.3.3 webgui/lib/tasks/possibility.rake
tournament-3.3.2 webgui/lib/tasks/possibility.rake
tournament-3.3.1 webgui/lib/tasks/possibility.rake
tournament-3.3.0 webgui/lib/tasks/possibility.rake
tournament-3.2.2 webgui/lib/tasks/possibility.rake
tournament-3.2.1 webgui/lib/tasks/possibility.rake
tournament-3.2.0 webgui/lib/tasks/possibility.rake
tournament-3.1.1 webgui/lib/tasks/possibility.rake
tournament-3.1.0 webgui/lib/tasks/possibility.rake