Skip to content

Commit

Permalink
fix: filter pending nervos_dao_deposit cell_outputs
Browse files Browse the repository at this point in the history
Signed-off-by: Miles Zhang <[email protected]>
  • Loading branch information
zmcNotafraid committed Dec 16, 2024
1 parent 06d7da0 commit 752ccc5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/models/cell_output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/workers/address_average_deposit_time_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 752ccc5

Please sign in to comment.