diff --git a/app/controllers/api/v1/address_transactions_controller.rb b/app/controllers/api/v1/address_transactions_controller.rb index 60b11f0b7..43f15b434 100644 --- a/app/controllers/api/v1/address_transactions_controller.rb +++ b/app/controllers/api/v1/address_transactions_controller.rb @@ -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) @@ -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) diff --git a/app/controllers/api/v2/ckb_transactions_controller.rb b/app/controllers/api/v2/ckb_transactions_controller.rb index 826244ab2..5e392e7fc 100644 --- a/app/controllers/api/v2/ckb_transactions_controller.rb +++ b/app/controllers/api/v2/ckb_transactions_controller.rb @@ -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, @@ -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 @@ -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 diff --git a/lib/scheduler.rb b/lib/scheduler.rb index ff8d0fa58..52c9b9d95 100644 --- a/lib/scheduler.rb +++ b/lib/scheduler.rb @@ -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