Skip to content

Commit

Permalink
Merge branch 'develop' into issue-256
Browse files Browse the repository at this point in the history
  • Loading branch information
rabbitz authored Dec 16, 2024
2 parents ba8ef62 + 564d351 commit 88583bf
Show file tree
Hide file tree
Showing 7 changed files with 331 additions and 198 deletions.
114 changes: 57 additions & 57 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,72 +10,72 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actioncable (7.0.8.5)
actionpack (= 7.0.8.5)
activesupport (= 7.0.8.5)
actioncable (7.0.8.7)
actionpack (= 7.0.8.7)
activesupport (= 7.0.8.7)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.8.5)
actionpack (= 7.0.8.5)
activejob (= 7.0.8.5)
activerecord (= 7.0.8.5)
activestorage (= 7.0.8.5)
activesupport (= 7.0.8.5)
actionmailbox (7.0.8.7)
actionpack (= 7.0.8.7)
activejob (= 7.0.8.7)
activerecord (= 7.0.8.7)
activestorage (= 7.0.8.7)
activesupport (= 7.0.8.7)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.8.5)
actionpack (= 7.0.8.5)
actionview (= 7.0.8.5)
activejob (= 7.0.8.5)
activesupport (= 7.0.8.5)
actionmailer (7.0.8.7)
actionpack (= 7.0.8.7)
actionview (= 7.0.8.7)
activejob (= 7.0.8.7)
activesupport (= 7.0.8.7)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.8.5)
actionview (= 7.0.8.5)
activesupport (= 7.0.8.5)
actionpack (7.0.8.7)
actionview (= 7.0.8.7)
activesupport (= 7.0.8.7)
rack (~> 2.0, >= 2.2.4)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.8.5)
actionpack (= 7.0.8.5)
activerecord (= 7.0.8.5)
activestorage (= 7.0.8.5)
activesupport (= 7.0.8.5)
actiontext (7.0.8.7)
actionpack (= 7.0.8.7)
activerecord (= 7.0.8.7)
activestorage (= 7.0.8.7)
activesupport (= 7.0.8.7)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.0.8.5)
activesupport (= 7.0.8.5)
actionview (7.0.8.7)
activesupport (= 7.0.8.7)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
active_interaction (5.3.0)
activemodel (>= 5.2, < 8)
activesupport (>= 5.2, < 8)
activejob (7.0.8.5)
activesupport (= 7.0.8.5)
activejob (7.0.8.7)
activesupport (= 7.0.8.7)
globalid (>= 0.3.6)
activemodel (7.0.8.5)
activesupport (= 7.0.8.5)
activerecord (7.0.8.5)
activemodel (= 7.0.8.5)
activesupport (= 7.0.8.5)
activemodel (7.0.8.7)
activesupport (= 7.0.8.7)
activerecord (7.0.8.7)
activemodel (= 7.0.8.7)
activesupport (= 7.0.8.7)
activerecord-import (1.4.1)
activerecord (>= 4.2)
activestorage (7.0.8.5)
actionpack (= 7.0.8.5)
activejob (= 7.0.8.5)
activerecord (= 7.0.8.5)
activesupport (= 7.0.8.5)
activestorage (7.0.8.7)
actionpack (= 7.0.8.7)
activejob (= 7.0.8.7)
activerecord (= 7.0.8.7)
activesupport (= 7.0.8.7)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.8.5)
activesupport (7.0.8.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
Expand Down Expand Up @@ -285,7 +285,7 @@ GEM
method_source (1.1.0)
mini_mime (1.1.5)
mini_portile2 (2.8.8)
minitest (5.25.1)
minitest (5.25.4)
minitest-reporters (1.6.1)
ansi
builder
Expand All @@ -308,12 +308,12 @@ GEM
net-protocol
newrelic_rpm (8.12.0)
nio4r (2.7.3)
nokogiri (1.16.8)
nokogiri (1.17.1)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.16.8-arm64-darwin)
nokogiri (1.17.1-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.8-x86_64-linux)
nokogiri (1.17.1-x86_64-linux)
racc (~> 1.4)
pagy (5.10.1)
activesupport
Expand Down Expand Up @@ -357,30 +357,30 @@ GEM
rack (>= 2.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.8.5)
actioncable (= 7.0.8.5)
actionmailbox (= 7.0.8.5)
actionmailer (= 7.0.8.5)
actionpack (= 7.0.8.5)
actiontext (= 7.0.8.5)
actionview (= 7.0.8.5)
activejob (= 7.0.8.5)
activemodel (= 7.0.8.5)
activerecord (= 7.0.8.5)
activestorage (= 7.0.8.5)
activesupport (= 7.0.8.5)
rails (7.0.8.7)
actioncable (= 7.0.8.7)
actionmailbox (= 7.0.8.7)
actionmailer (= 7.0.8.7)
actionpack (= 7.0.8.7)
actiontext (= 7.0.8.7)
actionview (= 7.0.8.7)
activejob (= 7.0.8.7)
activemodel (= 7.0.8.7)
activerecord (= 7.0.8.7)
activestorage (= 7.0.8.7)
activesupport (= 7.0.8.7)
bundler (>= 1.15.0)
railties (= 7.0.8.5)
railties (= 7.0.8.7)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.1)
loofah (~> 2.21)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (7.0.8.5)
actionpack (= 7.0.8.5)
activesupport (= 7.0.8.5)
railties (7.0.8.7)
actionpack (= 7.0.8.7)
activesupport (= 7.0.8.7)
method_source
rake (>= 12.2)
thor (~> 1.0)
Expand Down
1 change: 1 addition & 0 deletions app/models/cell_output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class CellOutput < ApplicationRecord
where.not(type_hash: nil).or(where.not(data_hash: nil))
}
scope :by_scripts, ->(lock_script_ids, type_script_ids) { where("lock_script_id IN (?) OR type_script_id IN (?)", lock_script_ids, type_script_ids) }
scope :established_status, -> { where(status: ["live", "dead"]) }

before_create :setup_address

Expand Down
29 changes: 29 additions & 0 deletions app/views/api/v2/scripts/deployed_cells.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
json.data do
json.deployed_cells @deployed_cells do |deployed_cell|
json.id deployed_cell.id
json.capacity deployed_cell.capacity
json.ckb_transaction_id deployed_cell.ckb_transaction_id
json.created_at deployed_cell.created_at
json.updated_at deployed_cell.updated_at
json.status deployed_cell.status
json.address_id deployed_cell.address_id
json.block_id deployed_cell.block_id
json.tx_hash deployed_cell.tx_hash
json.cell_index deployed_cell.cell_index
json.consumed_by_id deployed_cell.consumed_by_id
json.cell_type deployed_cell.cell_type
json.data_size deployed_cell.data_size
json.occupied_capacity deployed_cell.occupied_capacity
json.block_timestamp deployed_cell.block_timestamp
json.consumed_block_timestamp deployed_cell.consumed_block_timestamp
json.type_hash deployed_cell.type_hash
json.udt_amount deployed_cell.udt_amount
json.dao deployed_cell.dao
json.lock_script_id deployed_cell.lock_script_id
json.type_script_id deployed_cell.type_script_id
end
json.meta do
json.total @deployed_cells.total_count
json.page_size @page_size.to_i
end
end
29 changes: 29 additions & 0 deletions app/views/api/v2/scripts/referring_cells.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
json.data do
json.referring_cells @referring_cells do |referring_cell|
json.id referring_cell.id
json.capacity referring_cell.capacity
json.ckb_transaction_id referring_cell.ckb_transaction_id
json.created_at referring_cell.created_at
json.updated_at referring_cell.updated_at
json.status referring_cell.status
json.address_id referring_cell.address_id
json.block_id referring_cell.block_id
json.tx_hash referring_cell.tx_hash
json.cell_index referring_cell.cell_index
json.consumed_by_id referring_cell.consumed_by_id
json.cell_type referring_cell.cell_type
json.data_size referring_cell.data_size
json.occupied_capacity referring_cell.occupied_capacity
json.block_timestamp referring_cell.block_timestamp
json.consumed_block_timestamp referring_cell.consumed_block_timestamp
json.type_hash referring_cell.type_hash
json.udt_amount referring_cell.udt_amount
json.dao referring_cell.dao
json.lock_script_id referring_cell.lock_script_id
json.type_script_id referring_cell.type_script_id
end
json.meta do
json.total @referring_cells.total_count
json.page_size @page_size.to_i
end
end
2 changes: 1 addition & 1 deletion app/workers/address_average_deposit_time_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def cal_average_deposit_time(address, ended_at = CkbUtils.time_in_milliseconds(T
# we must calculate the locked duration from lock to unlock.
# for locking deposit cell
# we calculate the locked duration from lock to now.
address.cell_outputs.nervos_dao_deposit.each do |cell|
address.cell_outputs.established_status.nervos_dao_deposit.each do |cell|
total_deposits += cell.capacity
total_ckb_deposit_time += cell.capacity * ((cell.consumed_by_id ? cell.consumed_block_timestamp : ended_at) - cell.block_timestamp)
end
Expand Down
Loading

0 comments on commit 88583bf

Please sign in to comment.