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 cf2f62a commit 61ee504
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.where(udt_type: %i[xudt xudt_compatible], 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++"])

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 @@ -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

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#L40

Added line #L40 was not covered by tests
{ 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

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

Added line #L47 was not covered by tests
{ 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)

Check warning on line 70 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#L70

Added line #L70 was not covered by tests
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

Check warning on line 75 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#L75

Added line #L75 was not covered by tests
else
Time.current.yesterday
Time.now.yesterday

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

Added line #L77 was not covered by tests
end
end

Expand Down

0 comments on commit 61ee504

Please sign in to comment.