owncast/metrics/timestampedValue.go
Gabe Kangas 1ed1cc01eb
Persist time series viewer metrics (#1752)
* WIP persisting time series viewer metrics. Closes #1478

* Remove unused var, move around initial collection
2022-03-06 19:43:57 -08:00

21 lines
415 B
Go

package metrics
import (
"time"
"github.com/nakabonne/tstorage"
)
type timestampedValue struct {
Time time.Time `json:"time"`
Value int `json:"value"`
}
func makeTimestampedValuesFromDatapoints(dp []*tstorage.DataPoint) []timestampedValue {
tv := []timestampedValue{}
for _, d := range dp {
tv = append(tv, timestampedValue{Time: time.Unix(d.Timestamp, 0), Value: int(d.Value)})
}
return tv
}