Skip to content

Commit

Permalink
Merge pull request #1465 from nervosnetwork/develop
Browse files Browse the repository at this point in the history
Deploy to testnet
  • Loading branch information
rabbitz authored Oct 11, 2023
2 parents 3af1dbd + 755a05c commit 3354870
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
8 changes: 4 additions & 4 deletions app/controllers/api/v1/address_transactions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ class AddressTransactionsController < ApplicationController
before_action :set_address_transactions, only: [:show, :download_csv]

def show
@tx_ids = AccountBook.
joins(:ckb_transaction).
where(address_id: @address.id)
@tx_ids = AccountBook.joins(:ckb_transaction).
where(account_books: { address_id: @address.id },
ckb_transactions: { tx_status: "committed" })

params[:sort] ||= "ckb_transaction_id.desc"
order_by, asc_or_desc = params[:sort].split(".", 2)
Expand All @@ -29,7 +29,7 @@ def show
page(@page).per(@page_size).fast_page

order_by = "id" if order_by == "ckb_transaction_id"
@ckb_transactions = CkbTransaction.tx_committed.where(id: @tx_ids.map(&:ckb_transaction_id)).
@ckb_transactions = CkbTransaction.where(id: @tx_ids.map(&:ckb_transaction_id)).
select(:id, :tx_hash, :block_id, :block_number, :block_timestamp, :is_cellbase, :updated_at, :capacity_involved).
order(order_by => asc_or_desc)

Expand Down
14 changes: 8 additions & 6 deletions app/controllers/api/v2/ckb_transactions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ def build_cell_capacities(outputs)
udt_info = parsed_output.udt_info

if (cell_capacity = cell_capacities[[address, unit]]).blank?
capacity = unit == "CKB" ? parsed_output.capacity.to_f : 0.0
cell_capacity = {
capacity: capacity,
capacity: parsed_output.capacity.to_f,
cell_type: parsed_output.cell_type,
udt_info: {
symbol: udt_info&.symbol,
Expand All @@ -40,12 +39,12 @@ def build_cell_capacities(outputs)
published: !!udt_info&.published,
display_name: udt_info&.display_name,
uan: udt_info&.uan
}
},
m_nft_info: parsed_output.m_nft_info.to_h
}
elsif unit == "CKB"
cell_capacity[:capacity] += parsed_output.capacity.to_f
else
cell_capacity[:udt_info][:amount] += udt_info.amount.to_f
cell_capacity[:capacity] += parsed_output.capacity.to_f
cell_capacity[:udt_info][:amount] += udt_info.amount.to_f unless unit == "CKB"
end

cell_capacities[[address, unit]] = cell_capacity
Expand All @@ -65,8 +64,11 @@ def build_transfers(input_capacities, output_capacities)
# There may be keys in both input_capacities and output_capacities that do not exist
cell_type = output[:cell_type] || input[:cell_type]
capacity_change = output[:capacity].to_f - input[:capacity].to_f
m_nft_info = output[:m_nft_info] || input[:m_nft_info]

transfer = { capacity: capacity_change, cell_type: cell_type }
transfer[:m_nft_info] = m_nft_info if m_nft_info.present?

if unit != "CKB"
output_amount = output[:udt_info] ? output[:udt_info][:amount] : 0.0
input_amount = input[:udt_info] ? input[:udt_info][:amount] : 0.0
Expand Down
2 changes: 1 addition & 1 deletion lib/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def call_worker(clz)
ApplicationRecord.connection.execute "vacuum (verbose, analyze)"
end

s.cron "5 0 * * *" do
s.cron "0 8 * * *" do
call_worker Charts::DailyStatistic
end

Expand Down

0 comments on commit 3354870

Please sign in to comment.