Skip to content

Commit

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

def ft_count_attributes
timestamp = CkbUtils.time_in_milliseconds(ended_at) - 1
xudts_count = Udt.published_xudt.where(block_timestamp: ..timestamp).count
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++"])
{ indicator: "ft_count", value: xudts_count, network: "global" }
end

Expand All @@ -36,15 +37,14 @@ def dob_count_attributes
end

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

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
where(ckb_transactions: { block_timestamp: ..ended_timestamp }).count
{ indicator: "transactions_count", value: transactions_count, network: "ckb" }
end

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

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

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

Expand Down

0 comments on commit 569480d

Please sign in to comment.