From 697a34347f38d9872553d1201c38b00aa5bd84a3 Mon Sep 17 00:00:00 2001 From: Artem Poltorzhitskiy Date: Mon, 15 Jul 2024 22:42:24 +0200 Subject: [PATCH] Feature: add summary for gas used and gas limit per block (#250) --- cmd/api/docs/swagger.json | 2 +- cmd/api/markdown/summary.md | 2 ++ internal/storage/block_stats.go | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/api/docs/swagger.json b/cmd/api/docs/swagger.json index ebd55cc3..f2ab67cf 100644 --- a/cmd/api/docs/swagger.json +++ b/cmd/api/docs/swagger.json @@ -3723,7 +3723,7 @@ }, "/stats/summary/{table}/{function}": { "get": { - "description": "Returns string value by passed table and function.\n\n### Availiable tables\n* `block`\n* `block_stats`\n* `tx`\n* `message`\n* `event`\n\n\n### Availiable functions\n* `sum`\n* `min`\n* `max`\n* `avg`\n* `count`\n\n\n`Column` query parameter is required for functions `sum`, `min`, `max` and `avg` and should not pass for `count`.\n\n\n### Availiable columns and functions for tables:\n\n#### Block\n* `height` -- min max\n* `time` -- min max\n\n#### Block stats\n* `height` -- min max\n* `time` -- min max\n* `tx_count` -- min max sum avg\n* `events_count` -- min max sum avg\n* `blobs_size` -- min max sum avg\n* `block_time` -- min max sum avg\n* `supply_chnge` -- min max sum avg\n* `inflation_rate` -- min max avg\n* `fee` -- min max sum avg\n\n#### Tx\n* `height` -- min max\n* `time` -- min max\n* `gas_wanted` -- min max sum avg\n* `gas_used` -- min max sum avg\n* `timeout_height` -- min max avg\n* `events_count` -- min max sum avg\n* `messages_count` -- min max sum avg\n* `fee` -- min max sum avg\n\n#### Event\n* `height` -- min max\n* `time` -- min max\n\n#### Message\n* `height` -- min max\n* `time` -- min max", + "description": "Returns string value by passed table and function.\n\n### Availiable tables\n* `block`\n* `block_stats`\n* `tx`\n* `message`\n* `event`\n\n\n### Availiable functions\n* `sum`\n* `min`\n* `max`\n* `avg`\n* `count`\n\n\n`Column` query parameter is required for functions `sum`, `min`, `max` and `avg` and should not pass for `count`.\n\n\n### Availiable columns and functions for tables:\n\n#### Block\n* `height` -- min max\n* `time` -- min max\n\n#### Block stats\n* `height` -- min max\n* `time` -- min max\n* `tx_count` -- min max sum avg\n* `events_count` -- min max sum avg\n* `blobs_size` -- min max sum avg\n* `block_time` -- min max sum avg\n* `supply_chnge` -- min max sum avg\n* `inflation_rate` -- min max avg\n* `fee` -- min max sum avg\n* `gas_used` -- min max sum avg\n* `gas_limit` -- min max sum avg\n\n#### Tx\n* `height` -- min max\n* `time` -- min max\n* `gas_wanted` -- min max sum avg\n* `gas_used` -- min max sum avg\n* `timeout_height` -- min max avg\n* `events_count` -- min max sum avg\n* `messages_count` -- min max sum avg\n* `fee` -- min max sum avg\n\n#### Event\n* `height` -- min max\n* `time` -- min max\n\n#### Message\n* `height` -- min max\n* `time` -- min max", "produces": [ "application/json" ], diff --git a/cmd/api/markdown/summary.md b/cmd/api/markdown/summary.md index c5d26592..a7d5933e 100644 --- a/cmd/api/markdown/summary.md +++ b/cmd/api/markdown/summary.md @@ -35,6 +35,8 @@ Returns string value by passed table and function. * `supply_chnge` -- min max sum avg * `inflation_rate` -- min max avg * `fee` -- min max sum avg +* `gas_used` -- min max sum avg +* `gas_limit` -- min max sum avg #### Tx * `height` -- min max diff --git a/internal/storage/block_stats.go b/internal/storage/block_stats.go index 298a3259..5cd6d276 100644 --- a/internal/storage/block_stats.go +++ b/internal/storage/block_stats.go @@ -30,8 +30,8 @@ type BlockStats struct { BlobsSize int64 `bun:"blobs_size" comment:"Summary blocks size from pay for blob" stats:"func:min max sum avg"` BlobsCount int `bun:"blobs_count" comment:"Summary blobs count in the block" stats:"func:min max sum avg"` BlockTime uint64 `bun:"block_time" comment:"Time in milliseconds between current and previous block" stats:"func:min max sum avg"` - GasLimit int64 `bun:"gas_limit" comment:"Total gas limit in the block"` - GasUsed int64 `bun:"gas_used" comment:"Total gas used in the block"` + GasLimit int64 `bun:"gas_limit" comment:"Total gas limit in the block" stats:"func:min max sum avg"` + GasUsed int64 `bun:"gas_used" comment:"Total gas used in the block" stats:"func:min max sum avg"` SupplyChange decimal.Decimal `bun:",type:numeric" comment:"Change of total supply in the block" stats:"func:min max sum avg"` InflationRate decimal.Decimal `bun:",type:numeric" comment:"Inflation rate" stats:"func:min max avg"` Fee decimal.Decimal `bun:"fee,type:numeric" comment:"Summary block fee" stats:"func:min max sum avg"`