mirror of
https://github.com/owncast/owncast.git
synced 2024-12-18 15:23:55 +03:00
1ed1cc01eb
* WIP persisting time series viewer metrics. Closes #1478 * Remove unused var, move around initial collection
21 lines
415 B
Go
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
|
|
}
|