delete dead threads when cleaning up
This commit is contained in:
parent
5c06453f53
commit
4e18304369
15
honk.go
15
honk.go
|
@ -1299,6 +1299,21 @@ func serve() {
|
|||
|
||||
func cleanupdb() {
|
||||
db := opendatabase()
|
||||
rows, _ := db.Query("select userid, name from zonkers where wherefore = 'zonvoy'")
|
||||
deadthreads := make(map[int64][]string)
|
||||
for rows.Next() {
|
||||
var userid int64
|
||||
var name string
|
||||
rows.Scan(&userid, &name)
|
||||
deadthreads[userid] = append(deadthreads[userid], name)
|
||||
}
|
||||
rows.Close()
|
||||
for userid, threads := range deadthreads {
|
||||
for _, t := range threads {
|
||||
doordie(db, "delete from donks where honkid in (select honkid from honks where userid = ? and convoy = ?)", userid, t)
|
||||
doordie(db, "delete from honks where userid = ? and convoy = ?", userid, t)
|
||||
}
|
||||
}
|
||||
doordie(db, "delete from files where fileid not in (select fileid from donks)")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue