Class: Hive::Block

Inherits:
Base
  • Object
show all
Defined in:
lib/hive/models/block.rb

Overview

Tracks blocks.

To find blocks that have promoted posts:

blocks = Hive::Block.with_promoted_posts

With this result, we can get a list of post promoters in that block:

accounts = blocks.first.post_promoters

To find blocks that have normal intervals:

blocks = Hive::Block.block_interval(is: 3.seconds)

To find blocks that have longer than normal intervals:

blocks = Hive::Block.block_interval(min: 4.seconds)

To find blocks that have shorter than normal intervals:

blocks = Hive::Block.block_interval(max: 2.seconds)

To find blocks that have intervals in a certain range:

blocks = Hive::Block.block_interval(min: 15.seconds, max: 30.seconds)

Full report of slow blocks on the entire chain, grouped by date, sorted by the total slow blocks for that day:

puts JSON.pretty_generate Hive::Block.block_interval(min: 4.seconds).
  group('CAST(hive_blocks.created_at AS DATE)').order("count_all").count

Same report as above, grouped by month, sorted by the total slow blocks for that month:

puts JSON.pretty_generate Hive::Block.block_interval(min: 4.seconds).
  group("TO_CHAR(hive_blocks.created_at, 'YYYY-MM')").order("count_all").count

Same report as above, sorted by month:

puts JSON.pretty_generate Hive::Block.block_interval(min: 4.seconds).
  group("TO_CHAR(hive_blocks.created_at, 'YYYY-MM')").
  order("to_char_hive_blocks_created_at_yyyy_mm").count

Method Summary

Methods inherited from Base

delete, #delete, delete_all, transform_account_selector, #update, update_all