diff --git a/app/controllers/api/v2/scripts_controller.rb b/app/controllers/api/v2/scripts_controller.rb index 41347a4d9..c9835741e 100644 --- a/app/controllers/api/v2/scripts_controller.rb +++ b/app/controllers/api/v2/scripts_controller.rb @@ -17,21 +17,36 @@ 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 - @ckb_transactions = @contract.ckb_transactions.order(id: :desc).page(@page).per(@page_size) + @ckb_transactions = + if @contract.ckb_transactions_count.zero? + CkbTransaction.none + else + @contract.ckb_transactions.order(id: :desc).page(@page).per(@page_size) + end 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) + @deployed_cells = + if @contract.deployed_cells_count.zero? + CellOutput.none + else + @contract.deployed_cell_outputs.live.page(@page).per(@page_size) + end 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) + @referring_cells = + if @contract.referring_cells_count.zero? + CellOutput.none + else + @contract.referring_cell_outputs.live.page(@page).per(@page_size) + end end private