Fix removing inactive servers and avoid doing unneeded work.
This commit is contained in:
parent
9723c63912
commit
66cad28cf9
@ -42,7 +42,7 @@ func GetOldServers(db *gorm.DB, ts time.Time) []*Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func RemoveOldServers(db *gorm.DB, ts time.Time) {
|
func RemoveOldServers(db *gorm.DB, ts time.Time) {
|
||||||
db.Where("last_updated < datetime(?, '-7 days')").Delete(Server{})
|
db.Where("last_updated < datetime(?, '-7 days')", ts).Delete(Server{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetServerPopulation(db *gorm.DB, id int, d time.Duration) []*ServerPopulation {
|
func GetServerPopulation(db *gorm.DB, id int, d time.Duration) []*ServerPopulation {
|
||||||
|
|||||||
@ -39,17 +39,17 @@ func (i *Instance) UpdateServers() {
|
|||||||
i.update_server(s)
|
i.update_server(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if i.Debug {
|
||||||
|
fmt.Println("\nRemoving old servers...")
|
||||||
|
}
|
||||||
|
RemoveOldServers(i.DB, Now())
|
||||||
|
|
||||||
if i.Debug {
|
if i.Debug {
|
||||||
fmt.Println("\nUpdating inactive servers...")
|
fmt.Println("\nUpdating inactive servers...")
|
||||||
}
|
}
|
||||||
for _, s := range i.get_old_servers() {
|
for _, s := range i.get_old_servers() {
|
||||||
i.update_server(s)
|
i.update_server(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
if i.Debug {
|
|
||||||
fmt.Println("\nRemoving old servers...")
|
|
||||||
}
|
|
||||||
RemoveOldServers(i.DB, Now())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func reset() {
|
func reset() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user