Fix invalid nil time being returned
This commit is contained in:
parent
2c2736aef9
commit
d28c4b96f3
@ -328,7 +328,7 @@ func SetPeakOverallViewerCount(count int) error {
|
|||||||
|
|
||||||
// GetLastDisconnectTime will return the time the last stream ended.
|
// GetLastDisconnectTime will return the time the last stream ended.
|
||||||
func GetLastDisconnectTime() (utils.NullTime, error) {
|
func GetLastDisconnectTime() (utils.NullTime, error) {
|
||||||
var disconnectTime utils.NullTime
|
var disconnectTime = utils.NullTime{time.Now(), false}
|
||||||
configEntry, err := _datastore.Get(lastDisconnectTimeKey)
|
configEntry, err := _datastore.Get(lastDisconnectTimeKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return disconnectTime, err
|
return disconnectTime, err
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"github.com/owncast/owncast/geoip"
|
"github.com/owncast/owncast/geoip"
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
"github.com/owncast/owncast/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var l = &sync.RWMutex{}
|
var l = &sync.RWMutex{}
|
||||||
@ -145,19 +144,14 @@ func saveStats() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getSavedStats() models.Stats {
|
func getSavedStats() models.Stats {
|
||||||
savedLastDisconnectTime, savedLastDisconnectTimeErr := data.GetLastDisconnectTime()
|
savedLastDisconnectTime, _ := data.GetLastDisconnectTime()
|
||||||
|
|
||||||
var lastDisconnectTime utils.NullTime
|
|
||||||
if savedLastDisconnectTimeErr == nil && savedLastDisconnectTime.Valid {
|
|
||||||
lastDisconnectTime = savedLastDisconnectTime
|
|
||||||
}
|
|
||||||
|
|
||||||
result := models.Stats{
|
result := models.Stats{
|
||||||
ChatClients: make(map[string]models.Client),
|
ChatClients: make(map[string]models.Client),
|
||||||
Viewers: make(map[string]time.Time),
|
Viewers: make(map[string]time.Time),
|
||||||
SessionMaxViewerCount: data.GetPeakSessionViewerCount(),
|
SessionMaxViewerCount: data.GetPeakSessionViewerCount(),
|
||||||
OverallMaxViewerCount: data.GetPeakOverallViewerCount(),
|
OverallMaxViewerCount: data.GetPeakOverallViewerCount(),
|
||||||
LastDisconnectTime: lastDisconnectTime,
|
LastDisconnectTime: savedLastDisconnectTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the stats were saved > 5min ago then ignore the
|
// If the stats were saved > 5min ago then ignore the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user