Skip to content

Commit

Permalink
Feature: add hour timeframe to cumulative series (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky authored Jul 15, 2024
1 parent 697a343 commit 3bf2a5c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmd/api/docs/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cmd/api/handler/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (sh StatsHandler) Series(c echo.Context) error {
}

type seriesCumulativeRequest struct {
Timeframe string `example:"day" param:"timeframe" swaggertype:"string" validate:"required,oneof=day week month year"`
Timeframe string `example:"day" param:"timeframe" swaggertype:"string" validate:"required,oneof=hour day week month year"`
SeriesName string `example:"tps" param:"name" swaggertype:"string" validate:"required,oneof=blobs_size blobs_count fee tx_count gas_used gas_limit bytes_in_block supply_change"`
From int64 `example:"1692892095" query:"from" swaggertype:"integer" validate:"omitempty,min=1"`
To int64 `example:"1692892095" query:"to" swaggertype:"integer" validate:"omitempty,min=1"`
Expand All @@ -237,7 +237,7 @@ type seriesCumulativeRequest struct {
// @Description Get cumulative histogram with precomputed stats by series name and timeframe
// @Tags stats
// @ID stats-series-cumulative
// @Param timeframe path string true "Timeframe" Enums(day, week, month, year)
// @Param timeframe path string true "Timeframe" Enums(hour, day, week, month, year)
// @Param name path string true "Series name" Enums(blobs_size, blobs_count, fee, tx_count, gas_used, gas_limit, bytes_in_block, supply_change)
// @Param from query integer false "Time from in unix timestamp" mininum(1)
// @Param to query integer false "Time to in unix timestamp" mininum(1)
Expand Down
1 change: 1 addition & 0 deletions cmd/api/handler/stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ func (s *StatsTestSuite) TestCumulativeSeries() {
} {

for _, tf := range []storage.Timeframe{
storage.TimeframeHour,
storage.TimeframeDay,
storage.TimeframeWeek,
storage.TimeframeMonth,
Expand Down
2 changes: 2 additions & 0 deletions internal/storage/postgres/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ func (s Stats) NamespaceSeries(ctx context.Context, timeframe storage.Timeframe,
func (s Stats) CumulativeSeries(ctx context.Context, timeframe storage.Timeframe, name string, req storage.SeriesRequest) (response []storage.SeriesItem, err error) {
query := s.db.DB().NewSelect()
switch timeframe {
case storage.TimeframeHour:
query.Table(storage.ViewBlockStatsByHour)
case storage.TimeframeDay:
query.Table(storage.ViewBlockStatsByDay)
case storage.TimeframeWeek:
Expand Down

0 comments on commit 3bf2a5c

Please sign in to comment.