Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlignBucketStart ¶
AlignBucketStart rounds `t` down to the nearest `bucketSeconds` boundary. Used so the API and the rollup-writer agree on bucket edges to the second.
func BucketExpr ¶
BucketExpr returns the SQL expression that floors `created_at` to a bucket-aligned unix timestamp. Same shape on every dialect — only the epoch-extraction function differs.
The expression returns an integer number of seconds since the epoch, truncated down to the nearest `bucketSeconds` boundary. Group by this expression, count(*), and you have a contiguous-bucket histogram.
func DensifyBuckets ¶
func DensifyBuckets(rows []BucketedRow, startUnix int64, bucketSeconds int, nBuckets int) []int64
DensifyBuckets takes a sparse list of {bucketStart, count} rows from the DB and emits a dense `nBuckets`-long slice aligned to `startUnix`. Bucket indexes outside the range are dropped — they can't render in a heatmap of fixed width.
Types ¶
type BucketCount ¶
BucketCount represents one row of a bucketed count query.
type BucketedRow ¶
type BucketedRow struct {
BucketStart int64 `gorm:"column:bucket_start"`
Cnt int64 `gorm:"column:cnt"`
}
BucketedRow is the raw scan target for the GROUP BY query. Stays dialect-agnostic since every dialect returns BIGINT for FLOOR/CAST expressions.