2019-01-31 15:06:11 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func domainExportCleanupBegin() error {
|
|
|
|
go func() {
|
|
|
|
for {
|
|
|
|
statement := `
|
|
|
|
DELETE FROM exports
|
|
|
|
WHERE creationDate < $1;
|
|
|
|
`
|
2019-01-31 15:19:47 +08:00
|
|
|
_, err := db.Exec(statement, time.Now().UTC().AddDate(0, 0, -7))
|
2019-01-31 15:06:11 +08:00
|
|
|
if err != nil {
|
|
|
|
logger.Errorf("error cleaning up export rows: %v", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
time.Sleep(2 * time.Hour)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|