From 411e6f0a68152fce8c3f805ea45d6f8c41b732ca Mon Sep 17 00:00:00 2001 From: NanZhang Date: Sat, 7 Oct 2023 14:09:29 +0800 Subject: [PATCH 1/3] chore: update daily statistic worker cron (#1464) --- lib/scheduler.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 35e36c902e95f9ec4187939f4f0d9c86fce646b8 Mon Sep 17 00:00:00 2001 From: NanZhang Date: Sat, 7 Oct 2023 14:10:20 +0800 Subject: [PATCH 2/3] feat: transaction detail info add m_nft_info (#1463) * feat: transaction detail info add m_nft_info * chore: calc udt capacity --- .../api/v2/ckb_transactions_controller.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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 From 755a05ccc9362821a5d03b98df939c17d5e0046c Mon Sep 17 00:00:00 2001 From: NanZhang Date: Sun, 8 Oct 2023 17:48:06 +0800 Subject: [PATCH 3/3] fix: filter committed address transactions (#1466) --- app/controllers/api/v1/address_transactions_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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)