tweak uptime format on debug page

This commit is contained in:
Azareal 2020-02-24 21:48:16 +10:00
parent fb942fd100
commit 1ea023bb6d
1 changed files with 8 additions and 2 deletions

View File

@ -20,7 +20,8 @@ func Debug(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError {
dbVersion := qgen.Builder.DbVersion() dbVersion := qgen.Builder.DbVersion()
upDuration := time.Since(c.StartTime) upDuration := time.Since(c.StartTime)
hours := int(upDuration.Hours()) hours := int(upDuration.Hours())
minutes := int(upDuration.Minutes()) mins := int(upDuration.Minutes())
secs := int(upDuration.Seconds())
var uptime string var uptime string
if hours > 24 { if hours > 24 {
days := hours / 24 days := hours / 24
@ -28,9 +29,14 @@ func Debug(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError {
uptime += strconv.Itoa(days) + "d" uptime += strconv.Itoa(days) + "d"
uptime += strconv.Itoa(hours) + "h" uptime += strconv.Itoa(hours) + "h"
} else if hours >= 1 { } else if hours >= 1 {
mins -= hours * 60
uptime += strconv.Itoa(hours) + "h" uptime += strconv.Itoa(hours) + "h"
uptime += strconv.Itoa(mins) + "m"
} else if mins >= 1 {
secs -= mins * 60
uptime += strconv.Itoa(mins) + "m"
uptime += strconv.Itoa(secs) + "s"
} }
uptime += strconv.Itoa(minutes) + "m"
dbStats := qgen.Builder.GetConn().Stats() dbStats := qgen.Builder.GetConn().Stats()
openConnCount := dbStats.OpenConnections openConnCount := dbStats.OpenConnections