From 8f0baf6794db1bf943f8c3f7b3adf4d31a9b086d Mon Sep 17 00:00:00 2001 From: Rabbit Date: Mon, 21 Oct 2024 09:56:36 +0800 Subject: [PATCH] fix: calc udt holder allocation (#2253) --- app/workers/generate_udt_holder_allocation_worker.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/workers/generate_udt_holder_allocation_worker.rb b/app/workers/generate_udt_holder_allocation_worker.rb index b251fdbb5..e81fbd530 100644 --- a/app/workers/generate_udt_holder_allocation_worker.rb +++ b/app/workers/generate_udt_holder_allocation_worker.rb @@ -79,7 +79,8 @@ def calculate_holder_allocation_data(unique_ckb_address_ids) allocation_data = {} unique_ckb_address_ids.each_slice(500) do |batch_address_ids| - holder_counts = LockScript.where(address_id: batch_address_ids).group(:code_hash).count("DISTINCT address_id") + lock_script_ids = Address.where(id: batch_address_ids).map(&:lock_script_id).uniq + holder_counts = LockScript.where(id: lock_script_ids).group(:code_hash).count("DISTINCT id") holder_counts.each do |code_hash, count| allocation_data[code_hash] ||= 0 allocation_data[code_hash] += count