From 813ae079149ff5d5295cd23209ff31498d6ee6a0 Mon Sep 17 00:00:00 2001 From: NanZhang Date: Wed, 2 Aug 2023 08:09:31 +0800 Subject: [PATCH 1/2] Fix/import pending transaction (#1360) * chore: remove transaction * chore: workflow add explorer worker --- .github/workflows/mainnet.yml | 2 +- .github/workflows/staging.yml | 2 +- .github/workflows/testnet.yml | 2 +- .../migration/update_output_cells_status.rake | 30 ++++++++----------- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/.github/workflows/mainnet.yml b/.github/workflows/mainnet.yml index 8ce082a40..d586d4946 100644 --- a/.github/workflows/mainnet.yml +++ b/.github/workflows/mainnet.yml @@ -12,7 +12,7 @@ jobs: needs: build strategy: matrix: - workload: [ckb-explorer-api, ckb-explorer-poolsyncer, ckb-explorer-scheduler, ckb-explorer-blocksyncer] + workload: [ckb-explorer-api, ckb-explorer-poolsyncer, ckb-explorer-scheduler, ckb-explorer-blocksyncer, ckb-explorer-worker] uses: ./.github/workflows/update-image.yml with: k8s-namespace: mainnet diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index fe821e85c..6f0cfd3cc 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -16,7 +16,7 @@ jobs: needs: build strategy: matrix: - workload: [ckb-explorer-api, ckb-explorer-poolsyncer, ckb-explorer-scheduler, ckb-explorer-blocksyncer] + workload: [ckb-explorer-api, ckb-explorer-poolsyncer, ckb-explorer-scheduler, ckb-explorer-blocksyncer, ckb-explorer-worker] uses: ./.github/workflows/update-image.yml with: k8s-namespace: staging diff --git a/.github/workflows/testnet.yml b/.github/workflows/testnet.yml index 145515115..0286501a3 100644 --- a/.github/workflows/testnet.yml +++ b/.github/workflows/testnet.yml @@ -12,7 +12,7 @@ jobs: needs: build strategy: matrix: - workload: [ckb-explorer-api, ckb-explorer-poolsyncer, ckb-explorer-scheduler, ckb-explorer-blocksyncer] + workload: [ckb-explorer-api, ckb-explorer-poolsyncer, ckb-explorer-scheduler, ckb-explorer-blocksyncer, ckb-explorer-worker] uses: ./.github/workflows/update-image.yml with: k8s-namespace: testnet diff --git a/lib/tasks/migration/update_output_cells_status.rake b/lib/tasks/migration/update_output_cells_status.rake index fc48f7a48..ba078347a 100644 --- a/lib/tasks/migration/update_output_cells_status.rake +++ b/lib/tasks/migration/update_output_cells_status.rake @@ -2,23 +2,17 @@ class UpdateCellOutputsStatus include Rake::DSL def initialize - @address_ids = [] - namespace :migration do desc "Usage: RAILS_ENV=production bundle exec rake migration:update_output_cells_status" task update_output_cells_status: :environment do - ApplicationRecord.transaction do - CellOutput.pending.includes(:ckb_transaction).where(ckb_transaction: { tx_status: "committed" }).find_each do |output| - puts "output id: #{output.id}" + CellOutput.includes(:ckb_transaction).pending.where(ckb_transaction: { tx_status: "committed" }).find_each do |output| + puts "output id: #{output.id}" - output.live! - update_udt_account(output) - @address_ids << output.address_id - end + output.live! + update_udt_account(output) + update_address_live_cells_count(output.address_id) end - update_addresses_live_cells_count - puts "done" end end @@ -26,12 +20,14 @@ class UpdateCellOutputsStatus private - def update_addresses_live_cells_count - Address.where(id: @address_ids.uniq).find_each do |address| - address.live_cells_count = address.cell_outputs.live.count - address.cal_balance! - address.save! - end + def update_address_live_cells_count(address_id) + address = Address.find_by_id address_id + return unless address + + address.live_cells_count = address.cell_outputs.live.count + address.cal_balance! + address.save! + address.flush_cache end def update_udt_account(udt_output) From 63fe95dc47ae78c27744cb18dcfafe4f8628ffa6 Mon Sep 17 00:00:00 2001 From: Miles Zhang Date: Wed, 2 Aug 2023 08:18:41 +0800 Subject: [PATCH 2/2] chore: remove outputs response (#1362) Signed-off-by: Miles Zhang --- .github/workflows/update-image.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/update-image.yml b/.github/workflows/update-image.yml index baefa41d9..ea1b5c2e1 100644 --- a/.github/workflows/update-image.yml +++ b/.github/workflows/update-image.yml @@ -36,5 +36,4 @@ jobs: data: '{"kind":"deployments","namespace":"${{ inputs.k8s-namespace }}","name":"${{ inputs.k8s-workload }}","images":{"${{ inputs.image-name }}":"${{ inputs.image-name }}:${{ inputs.image-tag }}"}}' - name: Display Response run: | - echo "Response response: ${{ steps.http-request.outputs.response }}" echo "Response headers: ${{ steps.http-request.outputs.headers }}"