Skip to content

Commit

Permalink
fix: ckb hodl wave needs to calcualte dead cell_output after counted … (
Browse files Browse the repository at this point in the history
#1629)

fix: ckb hodl wave needs to calcualte dead cell_output after counted date

Signed-off-by: Miles Zhang <[email protected]>
  • Loading branch information
zmcNotafraid authored Feb 19, 2024
1 parent f65e75b commit 78e3feb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app/models/daily_statistic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def liquidity
over_three_years =
if time_range_exceeded?(3.years)
CellOutput.live.generated_before(to_be_counted_date.years_ago(3).to_i * 1000).sum(:capacity) +
CellOutput.dead.generated_before(to_be_counted_date.years_ago(3).to_i * 1000).consumed_after(to_be_counted_date.years_ago(3).to_i * 1000).sum(:capacity)
CellOutput.dead.generated_before(to_be_counted_date.years_ago(3).to_i * 1000).consumed_after(to_be_counted_date.to_i * 1000).sum(:capacity)
else
0
end
Expand All @@ -332,7 +332,7 @@ def liquidity
to_be_counted_date.years_ago(3).to_i * 1000, to_be_counted_date.years_ago(1).to_i * 1000
).sum(:capacity) + CellOutput.dead.generated_between(
to_be_counted_date.years_ago(3).to_i * 1000, to_be_counted_date.years_ago(1).to_i * 1000
).consumed_after(to_be_counted_date.years_ago(1).to_i * 1000).sum(:capacity)
).consumed_after(to_be_counted_date.to_i * 1000).sum(:capacity)
else
0
end
Expand All @@ -343,7 +343,7 @@ def liquidity
to_be_counted_date.years_ago(1).to_i * 1000, to_be_counted_date.months_ago(6).to_i * 1000
).sum(:capacity) + CellOutput.dead.generated_between(
to_be_counted_date.years_ago(1).to_i * 1000, to_be_counted_date.months_ago(6).to_i * 1000
).consumed_after(to_be_counted_date.months_ago(6).to_i * 1000).sum(:capacity)
).consumed_after(to_be_counted_date.to_i * 1000).sum(:capacity)
else
0
end
Expand All @@ -354,7 +354,7 @@ def liquidity
to_be_counted_date.months_ago(6).to_i * 1000, to_be_counted_date.months_ago(3).to_i * 1000
).sum(:capacity) + CellOutput.dead.generated_between(
to_be_counted_date.months_ago(6).to_i * 1000, to_be_counted_date.months_ago(3).to_i * 1000
).consumed_after(to_be_counted_date.months_ago(3).to_i * 1000).sum(:capacity)
).consumed_after(to_be_counted_date.to_i * 1000).sum(:capacity)
else
0
end
Expand All @@ -365,7 +365,7 @@ def liquidity
to_be_counted_date.months_ago(3).to_i * 1000, to_be_counted_date.months_ago(1).to_i * 1000
).sum(:capacity) + CellOutput.dead.generated_between(
to_be_counted_date.months_ago(3).to_i * 1000, to_be_counted_date.months_ago(1).to_i * 1000
).consumed_after(to_be_counted_date.months_ago(1).to_i * 1000).sum(:capacity)
).consumed_after(to_be_counted_date.to_i * 1000).sum(:capacity)
else
0
end
Expand All @@ -374,13 +374,13 @@ def liquidity
to_be_counted_date.months_ago(1).to_i * 1000, to_be_counted_date.weeks_ago(1).to_i * 1000
).sum(:capacity) + CellOutput.dead.generated_between(
to_be_counted_date.months_ago(1).to_i * 1000, to_be_counted_date.weeks_ago(1).to_i * 1000
).consumed_after(to_be_counted_date.weeks_ago(1).to_i * 1000).sum(:capacity)
).consumed_after(to_be_counted_date.to_i * 1000).sum(:capacity)

day_to_one_week = CellOutput.live.generated_between(
to_be_counted_date.weeks_ago(1).to_i * 1000, to_be_counted_date.days_ago(1).to_i * 1000
).sum(:capacity) + CellOutput.dead.generated_between(
to_be_counted_date.weeks_ago(1).to_i * 1000, to_be_counted_date.days_ago(1).to_i * 1000
).consumed_after(to_be_counted_date.days_ago(1).to_i * 1000).sum(:capacity)
).consumed_after(to_be_counted_date.to_i * 1000).sum(:capacity)

latest_day = CellOutput.live.generated_between(
to_be_counted_date.days_ago(1).to_i * 1000, to_be_counted_date.to_i * 1000
Expand Down

0 comments on commit 78e3feb

Please sign in to comment.