fix: 7b004463 part two
This commit is contained in:
parent
7b0044634a
commit
35096d1ed5
2 changed files with 17 additions and 14 deletions
|
|
@ -63,6 +63,8 @@ func HandleComputerWebSocket(w http.ResponseWriter, r *http.Request) {
|
|||
// Mark computer offline
|
||||
service.ComputerData.Online = false
|
||||
|
||||
// Calculate uptime only if we have a valid start time
|
||||
if service.ComputerData.UptimeStart > 0 {
|
||||
// Calculate uptime
|
||||
sessionUptime := int(time.Now().Unix()) - service.ComputerData.UptimeStart
|
||||
|
||||
|
|
@ -76,9 +78,10 @@ func HandleComputerWebSocket(w http.ResponseWriter, r *http.Request) {
|
|||
// Add to totals
|
||||
service.ComputerData.Totals.Uptime = totalUptime + float64(sessionUptime)
|
||||
storage.GlobalDataStore.Set("uptime", service.ComputerData.Totals.Uptime)
|
||||
}
|
||||
|
||||
// Reset uptime start (computer is offline)
|
||||
service.ComputerData.UptimeStart = 0
|
||||
// Set uptime start to -1 (computer is offline)
|
||||
service.ComputerData.UptimeStart = -1
|
||||
break
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
var ComputerData model.ComputerData = model.ComputerData{
|
||||
Online: false,
|
||||
UptimeStart: 0,
|
||||
UptimeStart: -1,
|
||||
Totals: model.ComputerTotals{
|
||||
Uptime: 0,
|
||||
Keys: 0,
|
||||
|
|
|
|||
Loading…
Reference in a new issue