all repos — honk @ 7c4c8c9aca55f638aef42b9db94843be13d78ff1

my fork of honk

add a reduce command to eliminate pic posters
Ted Unangst tedu@tedunangst.com
Sat, 08 Jun 2019 14:26:30 -0400
commit

7c4c8c9aca55f638aef42b9db94843be13d78ff1

parent

d090dba89763480c5872dd4afa1bd7584b8c4b26

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

jump to
M honk.gohonk.go

@@ -1344,6 +1344,14 @@ doordie(db, "delete from honks where dt < ? and whofore = 0 and convoy not in (select convoy from honks where whofore = 2 or whofore = 3)", expdate)

doordie(db, "delete from files where fileid not in (select fileid from donks)") } +func reducedb(honker string) { + db := opendatabase() + expdate := time.Now().UTC().Add(-3 * 24 * time.Hour).Format(dbtimeformat) + doordie(db, "delete from donks where honkid in (select honkid from honks where dt < ? and whofore = 0 and honker = ?)", expdate, honker) + doordie(db, "delete from honks where dt < ? and whofore = 0 and honker = ?", expdate, honker) + doordie(db, "delete from files where fileid not in (select fileid from donks)") +} + var stmtHonkers, stmtDubbers, stmtSaveHonker, stmtUpdateFlavor, stmtUpdateCombos *sql.Stmt var stmtOneXonk, stmtPublicHonks, stmtUserHonks, stmtHonksByCombo, stmtHonksByConvoy *sql.Stmt var stmtHonksForUser, stmtHonksForMe, stmtSaveDub *sql.Stmt

@@ -1428,6 +1436,11 @@ case "adduser":

adduser() case "cleanup": cleanupdb() + case "reduce": + if len(os.Args) < 3 { + log.Fatal("need a honker name") + } + reducedb(os.Args[2]) case "ping": if len(os.Args) < 4 { fmt.Printf("usage: honk ping from to\n")