-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2348 from nervosnetwork/testnet
Deploy to mainnet
- Loading branch information
Showing
28 changed files
with
631 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,9 +25,9 @@ jobs: | |
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: satackey/[email protected] | ||
# Ignore the failure of a step and avoid terminating the job. | ||
continue-on-error: true | ||
# - uses: satackey/[email protected] | ||
# # Ignore the failure of a step and avoid terminating the job. | ||
# continue-on-error: true | ||
- name: Build and push | ||
id: docker_build | ||
uses: mr-smithers-excellent/docker-build-push@v5 | ||
|
24 changes: 24 additions & 0 deletions
24
app/controllers/api/v2/rgbpp_assets_statistics_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Api | ||
module V2 | ||
class RgbppAssetsStatisticsController < BaseController | ||
def index | ||
expires_in 15.minutes, public: true, stale_while_revalidate: 5.minutes, stale_if_error: 5.minutes | ||
|
||
statistics = RgbppAssetsStatistic.all.order(created_at_unixtimestamp: :asc) | ||
statistics = statistics.where(network: params[:network]) if params[:network].present? | ||
statistics = statistics.where(indicator: params[:indicators].split(",")) if params[:indicators].present? | ||
|
||
render json: { | ||
data: statistics.map do |statistic| | ||
{ | ||
indicator: statistic.indicator, | ||
value: statistic.value.to_s, | ||
network: statistic.network, | ||
created_at_unixtimestamp: statistic.created_at_unixtimestamp.to_s, | ||
} | ||
end, | ||
} | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
app/controllers/api/v2/udt_hourly_statistics_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module Api | ||
module V2 | ||
class UdtHourlyStatisticsController < BaseController | ||
def show | ||
expires_in 15.minutes, public: true, stale_while_revalidate: 5.minutes, stale_if_error: 5.minutes | ||
|
||
udt = Udt.find_by!(type_hash: params[:id], published: true) | ||
hourly_statistics = | ||
if udt.present? | ||
UdtHourlyStatistic.where(udt:).order(created_at_unixtimestamp: :asc) | ||
else | ||
UdtHourlyStatistic.none | ||
end | ||
|
||
render json: { | ||
data: hourly_statistics.map do |statistic| | ||
{ | ||
ckb_transactions_count: statistic.ckb_transactions_count.to_s, | ||
amount: statistic.amount.to_s, | ||
holders_count: statistic.holders_count.to_s, | ||
created_at_unixtimestamp: statistic.created_at_unixtimestamp.to_s, | ||
} | ||
end, | ||
} | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class RgbppAssetsStatistic < ApplicationRecord | ||
enum :network, %i[global ckb btc] | ||
enum :indicator, %i[ft_count dob_count holders_count transactions_count] | ||
end | ||
|
||
# == Schema Information | ||
# | ||
# Table name: rgbpp_assets_statistics | ||
# | ||
# id :bigint not null, primary key | ||
# indicator :integer not null | ||
# value :decimal(40, ) default(0) | ||
# network :integer default("global") | ||
# created_at_unixtimestamp :integer | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_on_indicator_and_network_and_created_at_unixtimestamp (indicator,network,created_at_unixtimestamp) UNIQUE | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class RgbppHourlyStatistic < ApplicationRecord | ||
end | ||
|
||
# == Schema Information | ||
# | ||
# Table name: rgbpp_hourly_statistics | ||
# | ||
# id :bigint not null, primary key | ||
# xudt_count :integer default(0) | ||
# dob_count :integer default(0) | ||
# created_at_unixtimestamp :integer | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_rgbpp_hourly_statistics_on_created_at_unixtimestamp (created_at_unixtimestamp) UNIQUE | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
class UdtHourlyStatistic < ApplicationRecord | ||
belongs_to :udt | ||
|
||
def percentage_change(attribute) | ||
yesterday = previous_stat(udt_id, 1) | ||
day_before_yesterday = previous_stat(udt_id, 2) | ||
|
||
return nil unless yesterday && day_before_yesterday | ||
|
||
yesterday_value = yesterday.public_send(attribute) | ||
day_before_yesterday_value = day_before_yesterday.public_send(attribute) | ||
|
||
return nil if day_before_yesterday_value.zero? | ||
|
||
((yesterday_value - day_before_yesterday_value).to_f / day_before_yesterday_value * 100).round(2) | ||
end | ||
|
||
def previous_stat(udt_id, days_ago) | ||
timestamp = (Time.current - days_ago.days).beginning_of_day.to_i | ||
self.class.find_by(udt_id:, created_at_unixtimestamp: timestamp) | ||
end | ||
end | ||
|
||
# == Schema Information | ||
# | ||
# Table name: udt_hourly_statistics | ||
# | ||
# id :bigint not null, primary key | ||
# udt_id :bigint not null | ||
# ckb_transactions_count :integer default(0) | ||
# amount :decimal(40, ) default(0) | ||
# holders_count :integer default(0) | ||
# created_at_unixtimestamp :integer | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_on_udt_id_and_unixtimestamp (udt_id,created_at_unixtimestamp) UNIQUE | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.