Skip to content

Commit

Permalink
Merge pull request #571 from nervosnetwork/rc/v0.9.5
Browse files Browse the repository at this point in the history
[ᚬmaster] Rc/v0.9.5
  • Loading branch information
shaojunda authored Feb 26, 2020
2 parents b95b223 + 0d8e867 commit 5ce977e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# [v0.9.5](https://github.com/shaojunda/ckb-explorer/compare/v0.9.4...v0.9.5) (2020-02-26)

- prevent divided by 0 on average deposit time ([cabfa48](https://github.com/nervosnetwork/ckb-explorer/commit/cabfa48))

# [v0.9.4](https://github.com/shaojunda/ckb-explorer/compare/v0.9.3...v0.9.4) (2020-02-13)

### Features
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ GEM
connection_pool (~> 2.2)
newrelic_rpm (6.4.0.356)
nio4r (2.5.2)
nokogiri (1.10.5)
nokogiri (1.10.8)
mini_portile2 (~> 2.4.0)
numerizer (0.1.1)
open4 (1.3.4)
Expand Down
5 changes: 4 additions & 1 deletion app/services/charts/daily_statistic_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@ def average_deposit_time
memo + nervos_dao_deposit_cell.capacity * (ended_at - nervos_dao_deposit_cell.block_timestamp) / MILLISECONDS_IN_DAY
end

(sum_interest_bearing + sum_uninterest_bearing) / (interest_bearing_deposits + uninterest_bearing_deposits)
total_deposits = interest_bearing_deposits + uninterest_bearing_deposits
return 0 if total_deposits.zero?

(sum_interest_bearing + sum_uninterest_bearing) / total_deposits
end

def treasury_amount
Expand Down
3 changes: 2 additions & 1 deletion test/controllers/api/v1/dao_depositors_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class DaoDepositorsControllerTest < ActionDispatch::IntegrationTest
end

test "should get serialized dao depositors" do
addresses = create_list(:address, 10, dao_deposit: 1000)
create_list(:address, 10, dao_deposit: 1000)
addresses = Address.select(:id, :address_hash, :dao_deposit, :average_deposit_time).where("dao_deposit > 0").order(dao_deposit: :desc).limit(100)

valid_get api_v1_dao_depositors_url

Expand Down

0 comments on commit 5ce977e

Please sign in to comment.