Private
Public Access
1
0

scores: handle IPs with no current history
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-12-14 20:00:09 -08:00
parent f6b0f96a34
commit bae726dba6

View File

@@ -226,7 +226,8 @@ func (srv *Server) historyJSON(ctx context.Context, c echo.Context, server ntpdb
} }
} }
if history.LogScores[len(history.LogScores)-1].Ts.After(time.Now().Add(-8 * time.Hour)) { if len(history.LogScores) == 0 ||
history.LogScores[len(history.LogScores)-1].Ts.After(time.Now().Add(-8*time.Hour)) {
// cache for longer if data hasn't updated for a while // cache for longer if data hasn't updated for a while
c.Request().Header.Set("Cache-Control", "s-maxage=3600,max-age=1800") c.Request().Header.Set("Cache-Control", "s-maxage=3600,max-age=1800")
} else { } else {