Skip to content

Commit

Permalink
Merge pull request #2371 from nervosnetwork/develop
Browse files Browse the repository at this point in the history
Deploy to testnet
  • Loading branch information
rabbitz authored Dec 23, 2024
2 parents 99a38c8 + 5629fe4 commit 1664d75
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions app/workers/generate_rgbpp_assets_statistic_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,30 @@ def ft_count_attributes

def dob_count_attributes
timestamp = CkbUtils.time_in_milliseconds(ended_at) - 1
token_collections_count = TokenCollection.where("tags && ARRAY[?]::varchar[]", ["rgb++"]).
where(block_timestamp: ..timestamp).count
token_collections_count = TokenCollection.spore.where(block_timestamp: ..timestamp).count
{ indicator: "dob_count", value: token_collections_count, network: "global" }
end

Check warning on line 35 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#L31-L35

Added lines #L31 - L35 were not covered by tests

def btc_transactions_count_attributes
transactions_count = BitcoinTransaction.where(time: started_at.to_i..ended_at.to_i).count
transactions_count = BitcoinTransaction.where(time: ..ended_at.to_i).count
{ indicator: "transactions_count", value: transactions_count, network: "btc" }
end

Check warning on line 40 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#L37-L40

Added lines #L37 - L40 were not covered by tests

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

Check warning on line 43 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#L42-L43

Added lines #L42 - L43 were not covered by tests

ft_transaction_ids = Set.new
Udt.where(udt_type: %i[xudt xudt_compatible]).find_each do |xudt|
ft_transaction_ids.merge(xudt.ckb_transactions.where(block_timestamp: ..timestamp).ids)
end

Check warning on line 48 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-L48

Added lines #L45 - L48 were not covered by tests

dob_transaction_ids = Set.new
TokenCollection.spore.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 54 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#L50-L54

Added lines #L50 - L54 were not covered by tests

transactions_count = ft_transaction_ids.length + dob_transaction_ids.length
{ indicator: "transactions_count", value: transactions_count, network: "ckb" }
end

Check warning on line 58 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#L56-L58

Added lines #L56 - L58 were not covered by tests

Expand All @@ -67,14 +76,14 @@ def ckb_holders_count_attributes

def to_be_counted_date
if @datetime.present?
return Time.zone.parse(@datetime)
return Time.parse(@datetime)
end

Check warning on line 80 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#L77-L80

Added lines #L77 - L80 were not covered by tests

last_record = UdtHourlyStatistic.order(created_at_unixtimestamp: :desc).first
if last_record
Time.zone.at(last_record.created_at_unixtimestamp) + 1.day
Time.at(last_record.created_at_unixtimestamp) + 1.day
else
Time.current.yesterday
Time.now.yesterday
end
end

Check warning on line 88 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#L82-L88

Added lines #L82 - L88 were not covered by tests

Expand Down

0 comments on commit 1664d75

Please sign in to comment.