mirror of
https://github.com/owncast/owncast.git
synced 2026-03-13 09:51:16 +08:00
23 lines
475 B
Go
23 lines
475 B
Go
package metrics
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/nakabonne/tstorage"
|
|
)
|
|
|
|
// TimestampedValue is a value with a timestamp.
|
|
type TimestampedValue struct {
|
|
Time time.Time `json:"time"`
|
|
Value float64 `json:"value"`
|
|
}
|
|
|
|
func makeTimestampedValuesFromDatapoints(dp []*tstorage.DataPoint) []TimestampedValue {
|
|
tv := make([]TimestampedValue, 0, len(dp))
|
|
for _, d := range dp {
|
|
tv = append(tv, TimestampedValue{Time: time.Unix(d.Timestamp, 0), Value: d.Value})
|
|
}
|
|
|
|
return tv
|
|
}
|