tombstones for zonks

This commit is contained in:
Ted Unangst 2019-06-17 12:18:37 -04:00
parent 42d9306893
commit 22401dfbdb
2 changed files with 21 additions and 2 deletions

View File

@ -191,6 +191,19 @@ saveit:
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
@ -205,6 +218,10 @@ 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)
var id int64
err := row.Scan(&id)
@ -228,6 +245,7 @@ func savexonk(user *WhatAbout, x *Honk) {
log.Printf("error eradicating: %s", err)
}
}
stmtSaveZonker.Exec(user.ID, x.XID, "zonk")
return
}
log.Printf("saving xonk: %s", x.XID)

View File

@ -1424,7 +1424,7 @@ var stmtHonkers, stmtDubbers, stmtSaveHonker, stmtUpdateFlavor, stmtUpdateCombos
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 @@ func prepareStatements(db *sql.DB) {
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 (?, ?, ?)")