Skip to content

Commit

Permalink
Merge pull request #2043 from nervosnetwork/develop
Browse files Browse the repository at this point in the history
Deploy to testnet
  • Loading branch information
zmcNotafraid authored Jul 9, 2024
2 parents 9bb0980 + 1c68749 commit e1ac374
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
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,

Check warning on line 16 in app/workers/contract_statistic_worker.rb

View check run for this annotation

Codecov / codecov/patch

app/workers/contract_statistic_worker.rb#L16

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

Check warning on line 19 in app/workers/contract_statistic_worker.rb

View check run for this annotation

Codecov / codecov/patch

app/workers/contract_statistic_worker.rb#L18-L19

Added lines #L18 - L19 were not covered by tests
)
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

0 comments on commit e1ac374

Please sign in to comment.