Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/controllers/api/v1/blocks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ def index
head :not_found and return unless order_by.in? %w[number reward timestamp ckb_transactions_count]

blocks = blocks.order(order_by => asc_or_desc).order("number DESC").page(@page).per(@page_size)
total_count = TableRecordCount.find_by(table_name: "blocks")&.count

json =
Rails.cache.realize(blocks.cache_key, version: blocks.cache_version, race_condition_ttl: 3.seconds) do
options = FastJsonapi::PaginationMetaGenerator.new(request: request, records: blocks, page: @page,
page_size: @page_size).call
page_size: @page_size, total_count:).call
BlockListSerializer.new(blocks, options).serialized_json
end
end
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/api/v1/ckb_transactions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def index

ckb_transactions = ckb_transactions.order(order_by => asc_or_desc).
page(@page).per(@page_size).fast_page

total_count = TableRecordCount.find_by(table_name: "ckb_transactions")&.count
json =
Rails.cache.realize(ckb_transactions.cache_key,
version: ckb_transactions.cache_version, race_condition_ttl: 3.seconds) do
Expand All @@ -50,6 +50,7 @@ def index
records: ckb_transactions,
page: @page,
page_size: @page_size,
total_count:,
).call
CkbTransactionListSerializer.new(ckb_transactions,
options).serialized_json
Expand All @@ -66,7 +67,6 @@ def query
@address = Address.cached_find(params[:address])
end

total_count = 0
ckb_transactions =
if @address
@tx_ids =
Expand All @@ -80,8 +80,8 @@ def query
total_count = @tx_ids.total_count
CkbTransaction.where(id: @tx_ids.map(&:ckb_transaction_id)).order(block_number: :desc, tx_index: :desc)
else
txs = CkbTransaction.recent.normal.page(@page).per(@page_size).fast_page
total_count = txs.total_count
total_count = TableRecordCount.find_by(table_name: "ckb_transactions")&.count
CkbTransaction.recent.normal.page(@page).per(@page_size).fast_page
end
ckb_transactions = ckb_transactions.select(:id, :tx_hash, :block_id, :tags,
:block_number, :block_timestamp, :is_cellbase, :updated_at, :created_at)
Expand Down
Loading