tombstones for zonks
Ted Unangst tedu@tedunangst.com
Mon, 17 Jun 2019 12:18:37 -0400
2 files changed,
21 insertions(+),
2 deletions(-)
M
activity.go
→
activity.go
@@ -191,6 +191,19 @@ donk.FileID, _ = res.LastInsertId()
return &donk } +func iszonked(userid int64, xid string) bool { + row := stmtFindZonk.QueryRow(userid, xid) + var id int64 + err := row.Scan(&id) + if err == nil { + return true + } + if err != sql.ErrNoRows { + log.Printf("err querying zonk: %s", err) + } + return false +} + func needxonk(user *WhatAbout, x *Honk) bool { if x.What == "eradicate" { return true@@ -203,6 +216,10 @@ return needxonkid(user, x.XID)
} func needxonkid(user *WhatAbout, xid string) bool { if strings.HasPrefix(xid, user.URL+"/h/") { + return false + } + if iszonked(user.ID, xid) { + log.Printf("already zonked: %s", xid) return false } row := stmtFindXonk.QueryRow(user.ID, xid)@@ -228,6 +245,7 @@ if err != nil {
log.Printf("error eradicating: %s", err) } } + stmtSaveZonker.Exec(user.ID, x.XID, "zonk") return } log.Printf("saving xonk: %s", x.XID)
M
honk.go
→
honk.go
@@ -1424,7 +1424,7 @@ var stmtHonkers, stmtDubbers, stmtSaveHonker, stmtUpdateFlavor, stmtUpdateCombos *sql.Stmt
var stmtOneXonk, stmtPublicHonks, stmtUserHonks, stmtHonksByCombo, stmtHonksByConvoy *sql.Stmt var stmtHonksForUser, stmtHonksForMe, stmtSaveDub, stmtHonksByXonker *sql.Stmt var stmtHonksByHonker, stmtSaveHonk, stmtFileData, stmtWhatAbout *sql.Stmt -var stmtFindXonk, stmtSaveDonk, stmtFindFile, stmtSaveFile *sql.Stmt +var stmtFindZonk, stmtFindXonk, stmtSaveDonk, stmtFindFile, stmtSaveFile *sql.Stmt var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover *sql.Stmt var stmtHasHonker, stmtThumbBiters, stmtZonkIt, stmtZonkDonks, stmtSaveZonker *sql.Stmt var stmtGetZonkers, stmtRecentHonkers, stmtGetXonker, stmtSaveXonker *sql.Stmt@@ -1473,7 +1473,8 @@ stmtGetDoovers = preparetodie(db, "select dooverid, dt from doovers")
stmtLoadDoover = preparetodie(db, "select tries, username, rcpt, msg from doovers where dooverid = ?") stmtZapDoover = preparetodie(db, "delete from doovers where dooverid = ?") stmtThumbBiters = preparetodie(db, "select userid, name, wherefore from zonkers where (wherefore = 'zonker' or wherefore = 'zurl' or wherefore = 'zword')") - stmtGetZonkers = preparetodie(db, "select zonkerid, name, wherefore from zonkers where userid = ?") + stmtFindZonk = preparetodie(db, "select zonkerid from zonkers where userid = ? and name = ? and wherefore = 'zonk'") + stmtGetZonkers = preparetodie(db, "select zonkerid, name, wherefore from zonkers where userid = ? and wherefore <> 'zonk'") stmtSaveZonker = preparetodie(db, "insert into zonkers (userid, name, wherefore) values (?, ?, ?)") stmtGetXonker = preparetodie(db, "select info from xonkers where name = ? and flavor = ?") stmtSaveXonker = preparetodie(db, "insert into xonkers (name, info, flavor) values (?, ?, ?)")