Skip to content

Commit

Permalink
fix: refactor market_data api (#2428)
Browse files Browse the repository at this point in the history
Signed-off-by: Miles Zhang <mingchang555@hotmail.com>
  • Loading branch information
zmcNotafraid authored Feb 8, 2025
1 parent 20b9531 commit de35943
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/models/ckb_sync/new_node_data_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ def process_deposit_dao_events!(local_block, dao_contract)
}
end
DaoEvent.upsert_all(dao_events_attributes, unique_by: %i[block_id ckb_transaction_id cell_index event_type]) if dao_events_attributes.present?
Rails.cache.delete("unmade_dao_interests")
end
# update dao contract info
dao_contract.update!(
Expand Down
14 changes: 7 additions & 7 deletions app/models/market_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ def total_supply
def unmade_dao_interests
@unmade_dao_interests ||=
Rails.cache.fetch("unmade_dao_interests", expires_in: 1.day) do
# tip_dao = tip_block.dao
# total = 0
# CellOutput.nervos_dao_deposit.generated_before(tip_block.timestamp).unconsumed_at(tip_block.timestamp).find_each do |cell_output|
# total += DaoCompensationCalculator.new(cell_output, tip_dao).call
# end
# total
0
tip_dao = tip_block.dao
total = 0
DaoEvent.depositor.created_before(tip_block.timestamp).find_each do |dao_event|
cell_output = CellOutput.find_by(ckb_transaction_id: dao_event.ckb_transaction_id, cell_index: dao_event.cell_index)
total += DaoCompensationCalculator.new(cell_output, tip_dao).call
end
total
end
end

Expand Down

0 comments on commit de35943

Please sign in to comment.