Skip to content

Commit

Permalink
Merge pull request #2329 from nervosnetwork/develop
Browse files Browse the repository at this point in the history
Deploy to testnet
  • Loading branch information
rabbitz authored Dec 10, 2024
2 parents 0d8bc73 + 7c98d09 commit 5ff5114
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
15 changes: 4 additions & 11 deletions app/interactions/addresses/ckb_transactions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ def execute
raise AddressNotFoundError if address.is_a?(NullAddress)

address_id = address.map(&:id)
account_books = AccountBook.joins(:ckb_transaction).
where(account_books: { address_id: }, ckb_transactions: { tx_status: :committed }).
order(transactions_ordering).
select("DISTINCT account_books.ckb_transaction_id, ckb_transactions.block_timestamp, ckb_transactions.tx_index").
page(page).per(page_size)
records = CkbTransaction.where(id: account_books.map(&:ckb_transaction_id)).order(transactions_ordering)
account_books = AccountBook.where(address_id:).order("ckb_transaction_id desc").select(:ckb_transaction_id).distinct.limit(5000)
records = CkbTransaction.where(tx_status: :committed, id: account_books.map(&:ckb_transaction_id)).order(transactions_ordering).page(page).per(page_size)
options = paginate_options(records, address_id)
options.merge!(params: { previews: true, address: })
options.merge!(params: { previews: false, address: })

result = CkbTransactionsSerializer.new(records, options)
wrap_result(result, address)
Expand All @@ -37,10 +33,7 @@ def transactions_ordering
end

def paginate_options(records, address_id)
total_count = AccountBook.includes(:ckb_transaction).where(
account_books: { address_id: },
ckb_transactions: { tx_status: :committed },
).distinct.count(:ckb_transaction_id)
total_count = AccountBook.where(address_id:).distinct.count
FastJsonapi::PaginationMetaGenerator.new(
request:, records:, page:, page_size:, total_count:,
).call
Expand Down
11 changes: 1 addition & 10 deletions app/interactions/addresses/pending_transactions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,8 @@ def execute
address = Explore.run!(key:)
raise AddressNotFoundError if address.is_a?(NullAddress)

account_books =
AccountBook.joins(:ckb_transaction).where(
account_books: { address_id: address.map(&:id) },
ckb_transactions: { tx_status: "pending" },
)
ckb_transaction_ids =
CellInput.where(ckb_transaction_id: account_books.map(&:ckb_transaction_id)).
where.not(previous_cell_output_id: nil, from_cell_base: false).
distinct.pluck(:ckb_transaction_id)
records =
CkbTransaction.where(id: ckb_transaction_ids).
CkbTransaction.joins(:account_books).where(ckb_transactions: { tx_status: :pending }, account_books: { address_id: address.map(&:id) }).
select(select_fields).
order(transactions_ordering).
page(page).per(page_size)
Expand Down

0 comments on commit 5ff5114

Please sign in to comment.