Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy to testnet #2043

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/controllers/api/v2/statistics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def transaction_fees

def contract_resource_distributed
contracts = Contract.filter_nil_hash_type
if params[:code_hashes].present?
hashes = params[:code_hashes].split(",")
contracts = contracts.where(code_hash: hashes)
end
if stale?(contracts)
expires_in 30.minutes, public: true
json = contracts.map do |contract|
Expand Down
2 changes: 1 addition & 1 deletion app/workers/contract_statistic_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def perform
referring_cells_count: contract.referring_cell_outputs.live.size,
total_deployed_cells_capacity: contract.deployed_cell_outputs&.live&.sum(:capacity),
total_referring_cells_capacity: contract.referring_cell_outputs.live.sum(:capacity),
# addresses_count: ckb_address_ids.count,
addresses_count: ckb_address_ids.count,
)
end

Expand Down
9 changes: 9 additions & 0 deletions test/controllers/api/v2/statistics_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ class StatisticsControllerTest < ActionDispatch::IntegrationTest

assert_equal 3, data.size
end

test "return contracts resource distributed with code_hashes params" do
contracts = create_list(:contract, 3)

get contract_resource_distributed_api_v2_statistics_url, params: { code_hashes: "#{contracts[0].code_hash},#{contracts[1].code_hash}" }
data = JSON.parse(response.body)

assert_equal 2, data.size
end
end
end
end
Loading