diff --git a/app/models/cell_output.rb b/app/models/cell_output.rb index 53eda33ef..eeac7c120 100644 --- a/app/models/cell_output.rb +++ b/app/models/cell_output.rb @@ -107,6 +107,7 @@ class CellOutput < ApplicationRecord where.not(type_hash: nil).or(where.not(data_hash: nil)) } scope :by_scripts, ->(lock_script_ids, type_script_ids) { where("lock_script_id IN (?) OR type_script_id IN (?)", lock_script_ids, type_script_ids) } + scope :established_status, -> { where(status: ["live", "dead"]) } before_create :setup_address diff --git a/app/workers/address_average_deposit_time_generator.rb b/app/workers/address_average_deposit_time_generator.rb index 2f5fb9321..32b049102 100644 --- a/app/workers/address_average_deposit_time_generator.rb +++ b/app/workers/address_average_deposit_time_generator.rb @@ -22,7 +22,7 @@ def cal_average_deposit_time(address, ended_at = CkbUtils.time_in_milliseconds(T # we must calculate the locked duration from lock to unlock. # for locking deposit cell # we calculate the locked duration from lock to now. - address.cell_outputs.nervos_dao_deposit.each do |cell| + address.cell_outputs.established_status.nervos_dao_deposit.each do |cell| total_deposits += cell.capacity total_ckb_deposit_time += cell.capacity * ((cell.consumed_by_id ? cell.consumed_block_timestamp : ended_at) - cell.block_timestamp) end