From c9ab862c2181e0b82bcffd0696e41c82fac8097a Mon Sep 17 00:00:00 2001 From: Miles Zhang Date: Wed, 9 Oct 2024 14:24:31 +0800 Subject: [PATCH] fix: tx show order by tx_status asc (#2219) * fix: tx show order by tx_status asc Signed-off-by: Miles Zhang * test: fix test Signed-off-by: Miles Zhang --------- Signed-off-by: Miles Zhang --- app/controllers/api/v1/ckb_transactions_controller.rb | 2 +- test/factories/udt.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v1/ckb_transactions_controller.rb b/app/controllers/api/v1/ckb_transactions_controller.rb index dfcb070f9..d42c91368 100644 --- a/app/controllers/api/v1/ckb_transactions_controller.rb +++ b/app/controllers/api/v1/ckb_transactions_controller.rb @@ -137,7 +137,7 @@ def validate_query_params end def find_transaction - @ckb_transaction = CkbTransaction.where(tx_hash: params[:id]).order(tx_status: :desc).first + @ckb_transaction = CkbTransaction.where(tx_hash: params[:id]).order(tx_status: :asc).first raise Api::V1::Exceptions::CkbTransactionNotFoundError if @ckb_transaction.blank? end end diff --git a/test/factories/udt.rb b/test/factories/udt.rb index e660c95a6..d25fd65e5 100644 --- a/test/factories/udt.rb +++ b/test/factories/udt.rb @@ -21,9 +21,9 @@ 20.times do |i| block = create(:block, :with_block_hash) transaction = create(:ckb_transaction, block:, - contained_udt_ids: [udt.id], tags: ["udt"], tx_index: i + 2) + contained_udt_ids: [udt.id], tags: ["udt"], tx_index: i * 2) transaction1 = create(:ckb_transaction, block:, - contained_udt_ids: [udt.id], tags: ["udt"], tx_index: i + 1 == 1 ? 0 : i + 1) + contained_udt_ids: [udt.id], tags: ["udt"], tx_index: i * 2 + 1) cell_output = create(:cell_output, block:, ckb_transaction: transaction, consumed_by: transaction1,