From df94bdb4ed6b7f26db61f30803d3013816e5fc53 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sun, 6 Oct 2019 21:45:58 -0400 Subject: [PATCH] allow renaming shortnames --- database.go | 4 ++-- views/honkers.html | 1 + web.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/database.go b/database.go index e52d98c..d171a4a 100644 --- a/database.go +++ b/database.go @@ -504,7 +504,7 @@ func cleanupdb(arg string) { } } -var stmtHonkers, stmtDubbers, stmtSaveHonker, stmtUpdateFlavor, stmtUpdateCombos *sql.Stmt +var stmtHonkers, stmtDubbers, stmtSaveHonker, stmtUpdateFlavor, stmtUpdateHonker *sql.Stmt var stmtOneXonk, stmtPublicHonks, stmtUserHonks, stmtHonksByCombo, stmtHonksByConvoy *sql.Stmt var stmtHonksByOntology, stmtHonksForUser, stmtHonksForMe, stmtSaveDub, stmtHonksByXonker *sql.Stmt var stmtHonksBySearch, stmtHonksByHonker, stmtSaveHonk, stmtWhatAbout *sql.Stmt @@ -529,7 +529,7 @@ func prepareStatements(db *sql.DB) { stmtHonkers = preparetodie(db, "select honkerid, userid, name, xid, flavor, combos from honkers where userid = ? and (flavor = 'sub' or flavor = 'peep' or flavor = 'unsub') order by name") stmtSaveHonker = preparetodie(db, "insert into honkers (userid, name, xid, flavor, combos) values (?, ?, ?, ?, ?)") stmtUpdateFlavor = preparetodie(db, "update honkers set flavor = ? where userid = ? and xid = ? and flavor = ?") - stmtUpdateCombos = preparetodie(db, "update honkers set combos = ? where honkerid = ? and userid = ?") + stmtUpdateHonker = preparetodie(db, "update honkers set name = ?, combos = ? where honkerid = ? and userid = ?") stmtOneHonker = preparetodie(db, "select xid from honkers where name = ? and userid = ?") stmtDubbers = preparetodie(db, "select honkerid, userid, name, xid, flavor from honkers where userid = ? and flavor = 'dub'") diff --git a/views/honkers.html b/views/honkers.html index e5b20c0..7e10b3b 100644 --- a/views/honkers.html +++ b/views/honkers.html @@ -38,6 +38,7 @@ function expandstuff() {
+

name:

combos: {{ if eq .Flavor "sub" }}

unsub: diff --git a/web.go b/web.go index 25f3e52..9469186 100644 --- a/web.go +++ b/web.go @@ -1226,7 +1226,7 @@ func submithonker(w http.ResponseWriter, r *http.Request) { return } combos = " " + strings.TrimSpace(combos) + " " - _, err := stmtUpdateCombos.Exec(combos, honkerid, u.UserID) + _, err := stmtUpdateHonker.Exec(name, combos, honkerid, u.UserID) if err != nil { log.Printf("update honker err: %s", err) return