all repos — honk @ 039a5c36fa004f3096599b3b6f45a72e2ea3ed9d

my fork of honk

delete dead threads when cleaning up
Ted Unangst tedu@tedunangst.com
Wed, 22 May 2019 15:49:31 -0400
commit

039a5c36fa004f3096599b3b6f45a72e2ea3ed9d

parent

b4912550c2dfe3fb64d772ccb0db1c7b13d91a1a

1 files changed, 15 insertions(+), 0 deletions(-)

jump to
M honk.gohonk.go

@@ -1299,6 +1299,21 @@ }

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)") }