Skip to content

Commit

Permalink
feat: add epoch distribution info generation task
Browse files Browse the repository at this point in the history
  • Loading branch information
shaojunda committed Apr 30, 2020
1 parent 66d5d37 commit 42f53a3
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class EpochDistributionInfoGenerator
include Rake::DSL

def initialize
namespace :migration do
desc "Usage: RAILS_ENV=production bundle exec rake migration:fill_epoch_distribution_info"
task fill_epoch_distribution_info: :environment do
latest_epoch_statistic = EpochStatistic.order(epoch_number: :desc)[0]
epoch_statistic_generator = Charts::EpochStatisticGenerator.new(latest_epoch_statistic.epoch_number)

block_time_distribution = epoch_statistic_generator.send(:block_time_distribution)
epoch_time_distribution = epoch_statistic_generator.send(:epoch_time_distribution)
epoch_length_distribution = epoch_statistic_generator.send(:epoch_length_distribution)

latest_epoch_statistic.update(block_time_distribution: block_time_distribution, epoch_time_distribution: epoch_time_distribution, epoch_length_distribution: epoch_length_distribution)
puts "done"
end
end
end

private

end

EpochDistributionInfoGenerator.new

0 comments on commit 42f53a3

Please sign in to comment.