Skip to content

Commit

Permalink
chore: update rgbpp assets transactions count
Browse files Browse the repository at this point in the history
  • Loading branch information
rabbitz committed Dec 23, 2024
1 parent 61ee504 commit 25c4ade
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions app/workers/generate_rgbpp_assets_statistic_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def perform(datetime = nil)

def ft_count_attributes
timestamp = CkbUtils.time_in_milliseconds(ended_at) - 1
scope = Udt.where(udt_type: %i[xudt xudt_compatible], block_timestamp: ..timestamp)
xudts_count = scope.joins(:xudt_tag).where("xudt_tags.tags && ARRAY[?]::varchar[]", ["rgb++"])
xudts = Udt.where(udt_type: %i[xudt xudt_compatible], block_timestamp: ..timestamp)
xudts_count = xudts.joins(:xudt_tag).where("xudt_tags.tags && ARRAY[?]::varchar[]", ["rgb++"]).count

Check warning on line 28 in app/workers/generate_rgbpp_assets_statistic_worker.rb

View check run for this annotation

Codecov / codecov/patch

app/workers/generate_rgbpp_assets_statistic_worker.rb#L27-L28

Added lines #L27 - L28 were not covered by tests
{ indicator: "ft_count", value: xudts_count, network: "global" }
end

Expand All @@ -42,9 +42,21 @@ def btc_transactions_count_attributes
end

def ckb_transactions_count_attributes
ended_timestamp = CkbUtils.time_in_milliseconds(ended_at) - 1
transactions_count = BitcoinAnnotation.includes(:ckb_transaction).
where(ckb_transactions: { block_timestamp: ..ended_timestamp }).count
timestamp = CkbUtils.time_in_milliseconds(ended_at) - 1

Check warning on line 45 in app/workers/generate_rgbpp_assets_statistic_worker.rb

View check run for this annotation

Codecov / codecov/patch

app/workers/generate_rgbpp_assets_statistic_worker.rb#L45

Added line #L45 was not covered by tests

ft_transaction_ids = Set.new
xudts = Udt.where(udt_type: %i[xudt xudt_compatible])
xudts.joins(:xudt_tag).where("xudt_tags.tags && ARRAY[?]::varchar[]", ["rgb++"]).find_each do |xudt|
ft_transaction_ids.merge(xudt.ckb_transactions.where(block_timestamp: ..timestamp).ids)
end

Check warning on line 51 in app/workers/generate_rgbpp_assets_statistic_worker.rb

View check run for this annotation

Codecov / codecov/patch

app/workers/generate_rgbpp_assets_statistic_worker.rb#L47-L51

Added lines #L47 - L51 were not covered by tests

dob_transaction_ids = Set.new
TokenCollection.where("tags && ARRAY[?]::varchar[]", ["rgb++"]).find_each do |token_collection|
transfers = token_collection.transfers.joins(:ckb_transaction).where("ckb_transactions.block_timestamp <= ?", timestamp)
dob_transaction_ids.merge(transfers.map(&:transaction_id))
end

Check warning on line 57 in app/workers/generate_rgbpp_assets_statistic_worker.rb

View check run for this annotation

Codecov / codecov/patch

app/workers/generate_rgbpp_assets_statistic_worker.rb#L53-L57

Added lines #L53 - L57 were not covered by tests

transactions_count = ft_transaction_ids.length + dob_transaction_ids.length

Check warning on line 59 in app/workers/generate_rgbpp_assets_statistic_worker.rb

View check run for this annotation

Codecov / codecov/patch

app/workers/generate_rgbpp_assets_statistic_worker.rb#L59

Added line #L59 was not covered by tests
{ indicator: "transactions_count", value: transactions_count, network: "ckb" }
end

Expand Down

0 comments on commit 25c4ade

Please sign in to comment.