Use database time for liveness calculation (#1368)

pull/1360/head^2
Jeff Mitchell 5 years ago committed by GitHub
parent 7f9bc768a0
commit db269c968d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -69,13 +69,12 @@ func (r *Repository) listServersWithReader(ctx context.Context, reader db.Reader
if liveness == 0 {
liveness = defaultLiveness
}
updateTime := time.Now().Add(-1 * liveness)
var servers []*Server
if err := reader.SearchWhere(
ctx,
&servers,
"type = $1 and update_time > $2",
[]interface{}{serverType, updateTime.Format(time.RFC3339)},
fmt.Sprintf("type = $1 and update_time > now() - interval '%d seconds'", uint32(liveness.Seconds())),
[]interface{}{serverType},
db.WithLimit(-1),
); err != nil {
return nil, errors.Wrap(err, "servers.listServersWithReader")

Loading…
Cancel
Save