Skip to content

Commit

Permalink
fix: enhance dead cell_outputs count query (#2213)
Browse files Browse the repository at this point in the history
Signed-off-by: Miles Zhang <[email protected]>
  • Loading branch information
zmcNotafraid authored Oct 8, 2024
1 parent f24cff6 commit 6d8cc5e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions app/models/cell_output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,12 @@ def self.update_cell_types_for_cota
end
end
end

def self.dead_reltuples_count
sql = "SELECT reltuples FROM pg_class WHERE relname = 'cell_outputs_dead'"
result = ActiveRecord::Base.connection.execute(sql)
result.getvalue(0, 0).to_i
end
end

# == Schema Information
Expand Down
10 changes: 5 additions & 5 deletions app/services/charts/block_statistic_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ def call

hash_rate = StatisticInfo.hash_rate(block_number)
live_cells_count = CellOutput.live.count
dead_cells_count = CellOutput.dead.count
block_statistic = ::BlockStatistic.find_or_create_by(block_number: block_number)
dead_cells_count = CellOutput.dead_reltuples_count
block_statistic = ::BlockStatistic.find_or_create_by(block_number:)
block_statistic.update(epoch_number: target_block.epoch,
difficulty: target_block.difficulty,
hash_rate: hash_rate,
live_cells_count: live_cells_count,
dead_cells_count: dead_cells_count)
hash_rate:,
live_cells_count:,
dead_cells_count:)
end

private
Expand Down

0 comments on commit 6d8cc5e

Please sign in to comment.