diff --git a/app/controllers/api/v2/scripts_controller.rb b/app/controllers/api/v2/scripts_controller.rb index 63c80ce39..f3bdfdfb9 100644 --- a/app/controllers/api/v2/scripts_controller.rb +++ b/app/controllers/api/v2/scripts_controller.rb @@ -17,24 +17,21 @@ def ckb_transactions head :not_found and return if @contract.blank? expires_in 15.seconds, public: true, must_revalidate: true, stale_while_revalidate: 5.seconds - scope = CellDependency.where(contract_id: @contract.id).order(ckb_transaction_id: :desc) - tx_ids = scope.page(@page).per(@page_size).pluck(:ckb_transaction_id) - @ckb_transactions = CkbTransaction.find(tx_ids) - @total = scope.count + @ckb_transactions = @contract.ckb_transactions.order(id: :desc).page(@page).per(@page_size) end def deployed_cells head :not_found and return if @contract.blank? expires_in 15.seconds, public: true, must_revalidate: true, stale_while_revalidate: 5.seconds - @deployed_cells = @contract.deployed_cell_outputs.live.page(@page).per(@page_size).fast_page + @deployed_cells = @contract.deployed_cell_outputs.live.page(@page).per(@page_size) end def referring_cells head :not_found and return if @contract.blank? expires_in 15.seconds, public: true, must_revalidate: true, stale_while_revalidate: 5.seconds - @referring_cells = @contract.referring_cell_outputs.live.page(@page).per(@page_size).fast_page + @referring_cells = @contract.referring_cell_outputs.live.page(@page).per(@page_size) end private diff --git a/app/views/api/v2/scripts/ckb_transactions.json.jbuilder b/app/views/api/v2/scripts/ckb_transactions.json.jbuilder index 3ee41a87d..19b211f84 100644 --- a/app/views/api/v2/scripts/ckb_transactions.json.jbuilder +++ b/app/views/api/v2/scripts/ckb_transactions.json.jbuilder @@ -23,7 +23,7 @@ json.data do json.display_outputs tx.display_outputs end json.meta do - json.total @total + json.total @contract.ckb_transactions_count json.page_size @page_size.to_i end end diff --git a/app/views/api/v2/scripts/deployed_cells.json.jbuilder b/app/views/api/v2/scripts/deployed_cells.json.jbuilder index ddf21033d..ad742d4ea 100644 --- a/app/views/api/v2/scripts/deployed_cells.json.jbuilder +++ b/app/views/api/v2/scripts/deployed_cells.json.jbuilder @@ -23,7 +23,7 @@ json.data do json.type_script_id deployed_cell.type_script_id end json.meta do - json.total @deployed_cells.total_count + json.total @contract.deployed_cells_count json.page_size @page_size.to_i end end diff --git a/app/views/api/v2/scripts/referring_cells.json.jbuilder b/app/views/api/v2/scripts/referring_cells.json.jbuilder index c496c2e9e..4e13e3c26 100644 --- a/app/views/api/v2/scripts/referring_cells.json.jbuilder +++ b/app/views/api/v2/scripts/referring_cells.json.jbuilder @@ -23,7 +23,7 @@ json.data do json.type_script_id referring_cell.type_script_id end json.meta do - json.total @referring_cells.total_count + json.total @contract.referring_cells_count json.page_size @page_size.to_i end end