all repos — honk @ 49dc0802d5e134c9dd377864879d958b597ea2a5

my fork of honk

rework honkmeta deletion for flexibility
Ted Unangst tedu@tedunangst.com
Wed, 27 Nov 2019 14:22:20 -0500
commit

49dc0802d5e134c9dd377864879d958b597ea2a5

parent

7c24aac3d0f284da536834b968e6463f857d7ada

1 files changed, 12 insertions(+), 9 deletions(-)

jump to
M database.godatabase.go

@@ -491,7 +491,7 @@ log.Printf("can't begin tx: %s", err)

return err } - err = deleteextras(tx, h.ID) + err = deleteextras(tx, h.ID, false) if err == nil { _, err = tx.Stmt(stmtUpdateHonk).Exec(h.Precis, h.Noise, h.Format, h.Whofore, dt, h.ID) }

@@ -527,10 +527,7 @@ log.Printf("can't begin tx: %s", err)

return err } - err = deleteextras(tx, honkid) - if err == nil { - _, err = tx.Stmt(stmtDeleteMeta).Exec(honkid, "nonsense") - } + err = deleteextras(tx, honkid, true) if err == nil { _, err = tx.Stmt(stmtDeleteHonk).Exec(honkid) }

@@ -583,7 +580,7 @@ }

return nil } -func deleteextras(tx *sql.Tx, honkid int64) error { +func deleteextras(tx *sql.Tx, honkid int64, everything bool) error { _, err := tx.Stmt(stmtDeleteDonks).Exec(honkid) if err != nil { return err

@@ -592,7 +589,11 @@ _, err = tx.Stmt(stmtDeleteOnts).Exec(honkid)

if err != nil { return err } - _, err = tx.Stmt(stmtDeleteMeta).Exec(honkid, "oldrev") + if everything { + _, err = tx.Stmt(stmtDeleteAllMeta).Exec(honkid) + } else { + _, err = tx.Stmt(stmtDeleteSomeMeta).Exec(honkid) + } if err != nil { return err }

@@ -691,7 +692,8 @@ var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover, stmtOneHonker *sql.Stmt

var stmtUntagged, stmtDeleteHonk, stmtDeleteDonks, stmtDeleteOnts, stmtSaveZonker *sql.Stmt var stmtGetZonkers, stmtRecentHonkers, stmtGetXonker, stmtSaveXonker, stmtDeleteXonker *sql.Stmt var stmtAllOnts, stmtSaveOnt, stmtUpdateFlags, stmtClearFlags *sql.Stmt -var stmtHonksForUserFirstClass, stmtSaveMeta, stmtDeleteMeta, stmtUpdateHonk *sql.Stmt +var stmtHonksForUserFirstClass *sql.Stmt +var stmtSaveMeta, stmtDeleteAllMeta, stmtDeleteSomeMeta, stmtUpdateHonk *sql.Stmt var stmtHonksISaved, stmtGetFilters, stmtSaveFilter, stmtDeleteFilter *sql.Stmt var stmtGetTracks *sql.Stmt

@@ -735,7 +737,8 @@ stmtHonksByConvoy = preparetodie(db, selecthonks+"where honks.honkid > ? and (honks.userid = ? or (? = -1 and whofore = 2)) and convoy = ?"+limit)

stmtHonksByOntology = preparetodie(db, selecthonks+"join onts on honks.honkid = onts.honkid where honks.honkid > ? and onts.ontology = ? and (honks.userid = ? or (? = -1 and honks.whofore = 2))"+limit) stmtSaveMeta = preparetodie(db, "insert into honkmeta (honkid, genus, json) values (?, ?, ?)") - stmtDeleteMeta = preparetodie(db, "delete from honkmeta where honkid = ? and genus <> ?") + stmtDeleteAllMeta = preparetodie(db, "delete from honkmeta where honkid = ?") + stmtDeleteSomeMeta = preparetodie(db, "delete from honkmeta where honkid = ? and genus not in ('oldrev')") stmtSaveHonk = preparetodie(db, "insert into honks (userid, what, honker, xid, rid, dt, url, audience, noise, convoy, whofore, format, precis, oonker, flags) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") stmtDeleteHonk = preparetodie(db, "delete from honks where honkid = ?") stmtUpdateHonk = preparetodie(db, "update honks set precis = ?, noise = ?, format = ?, whofore = ?, dt = ? where honkid = ?")