From 5039881ba6382e92ac61d75f4de6c6407b304a89 Mon Sep 17 00:00:00 2001 From: Rabbit Date: Tue, 9 Jul 2024 12:14:51 +0800 Subject: [PATCH] chore: optimize rgb_cells with status filter (#2045) --- app/controllers/api/v2/bitcoin_addresses_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v2/bitcoin_addresses_controller.rb b/app/controllers/api/v2/bitcoin_addresses_controller.rb index 237357ada..8bb756356 100644 --- a/app/controllers/api/v2/bitcoin_addresses_controller.rb +++ b/app/controllers/api/v2/bitcoin_addresses_controller.rb @@ -36,7 +36,9 @@ def rgb_cells cells = bitcoin_vouts.each_with_object({}) do |vout, hash| tx = transactions[vout.bitcoin_transaction_id] - vouts = BitcoinVout.where(bitcoin_transaction_id: vout.bitcoin_transaction_id, index: vout.index).includes(:cell_output) + vouts = BitcoinVout.where(bitcoin_transaction_id: vout.bitcoin_transaction_id, index: vout.index).includes(:cell_output).where( + cell_outputs: { status: "live" }, + ) hash[[tx.tx_hash, vout.index]] = vouts.map { |v| CellOutputSerializer.new(v.cell_output).serializable_hash } end