Skip to content

Commit

Permalink
Fix: percentage
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Jun 15, 2024
1 parent dfea3a8 commit 514f660
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions internal/storage/postgres/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ func (s Stats) SummaryTimeframe(ctx context.Context, timeframe storage.Timeframe
With("prev", prev).
Table("curr", "prev").
ColumnExpr("curr.data_size as data_size, curr.tx_count as tx_count, curr.bytes_in_block as bytes_in_block, curr.tps as tps, curr.bps as bps, curr.rbps as rbps, curr.block_time as block_time").
ColumnExpr("case when prev.data_size = 0 then 1 else (curr.data_size - prev.data_size) * 100 / prev.data_size end as data_size_pct").
ColumnExpr("case when prev.tx_count = 0 then 1 else (curr.tx_count - prev.tx_count)* 100 / prev.tx_count end as tx_count_pct").
ColumnExpr("case when prev.bytes_in_block = 0 then 1 else (curr.bytes_in_block - prev.bytes_in_block)* 100 / prev.bytes_in_block end as bytes_in_block_pct").
ColumnExpr("case when prev.tps = 0 then 1 else (curr.tps - prev.tps)* 100 / prev.tps end as tps_pct").
ColumnExpr("case when prev.bps = 0 then 1 else (curr.bps - prev.bps)* 100 / prev.bps end as bps_pct").
ColumnExpr("case when prev.rbps = 0 then 1 else (curr.rbps - prev.rbps)* 100 / prev.rbps end as rbps_pct").
ColumnExpr("case when prev.block_time = 0 then 1 else (curr.block_time - prev.block_time)* 100 / prev.block_time end as block_time_pct").
ColumnExpr("case when prev.data_size = 0 then 100 else (curr.data_size - prev.data_size) * 100 / prev.data_size end as data_size_pct").
ColumnExpr("case when prev.tx_count = 0 then 100 else (curr.tx_count - prev.tx_count)* 100 / prev.tx_count end as tx_count_pct").
ColumnExpr("case when prev.bytes_in_block = 0 then 100 else (curr.bytes_in_block - prev.bytes_in_block)* 100 / prev.bytes_in_block end as bytes_in_block_pct").
ColumnExpr("case when prev.tps = 0 then 100 else (curr.tps - prev.tps)* 100 / prev.tps end as tps_pct").
ColumnExpr("case when prev.bps = 0 then 100 else (curr.bps - prev.bps)* 100 / prev.bps end as bps_pct").
ColumnExpr("case when prev.rbps = 0 then 100 else (curr.rbps - prev.rbps)* 100 / prev.rbps end as rbps_pct").
ColumnExpr("case when prev.block_time = 0 then 100 else (curr.block_time - prev.block_time)* 100 / prev.block_time end as block_time_pct").
Scan(ctx, &summary)

return
Expand Down

0 comments on commit 514f660

Please sign in to comment.