Skip to content

Commit

Permalink
Merge pull request #2350 from nervosnetwork/develop
Browse files Browse the repository at this point in the history
Deploy to testnet
  • Loading branch information
rabbitz authored Dec 16, 2024
2 parents 1deeccc + 1b35118 commit 87dd3a1
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions app/workers/generate_udt_hourly_statistic_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ def generate_statistics(start_time)
def calc_amount(udt)
inputs_amount = 0
outputs_amount = 0
ckb_transaction_ids = udt.ckb_transactions.map(&:id)
ckb_transaction_ids.each_slice(5000) do |ids|
batch_inputs_amount = CellOutput.select(:udt_amount).where(consumed_by_id: ids).map(&:udt_amount).compact
inputs_amount += batch_inputs_amount.sum
batch_outputs_amount = CellOutput.select(:udt_amount).where(ckb_transaction_id: ids).map(&:udt_amount).compact
outputs_amount += batch_outputs_amount.sum
udt.ckb_transactions.includes(:cell_outputs).find_in_batches(batch_size: 1000) do |transactions|
ids = transactions.map(&:id)
inputs_amount += CellOutput.select(:udt_amount).where(consumed_by_id: ids).sum(:udt_amount)
outputs_amount += CellOutput.select(:udt_amount).where(ckb_transaction_id: ids).sum(:udt_amount)
end
[inputs_amount, outputs_amount].max
end

Check warning on line 52 in app/workers/generate_udt_hourly_statistic_worker.rb

View check run for this annotation

Codecov / codecov/patch

app/workers/generate_udt_hourly_statistic_worker.rb#L43-L52

Added lines #L43 - L52 were not covered by tests
Expand Down

0 comments on commit 87dd3a1

Please sign in to comment.