all repos — honk @ 379ea486c1cc0408b2c9602bb6fe60b1972103b0

my fork of honk

combine common code
Ted Unangst tedu@tedunangst.com
Mon, 16 Sep 2019 16:46:14 -0400
commit

379ea486c1cc0408b2c9602bb6fe60b1972103b0

parent

f1427e327430557fad4d441d7e989eaa4465a2d5

1 files changed, 8 insertions(+), 19 deletions(-)

jump to
M database.godatabase.go

@@ -90,10 +90,10 @@ }

return users } -func getxonk(userid int64, xid string) *Honk { +func scanxonk(row *sql.Row) *Honk { h := new(Honk) var dt, aud, onts string - row := stmtOneXonk.QueryRow(userid, xid) + err := row.Scan(&h.ID, &h.UserID, &h.Username, &h.What, &h.Honker, &h.Oonker, &h.XID, &h.RID, &dt, &h.URL, &aud, &h.Noise, &h.Precis, &h.Convoy, &h.Whofore, &h.Flags, &onts) if err != nil {

@@ -111,25 +111,14 @@ }

return h } +func getxonk(userid int64, xid string) *Honk { + row := stmtOneXonk.QueryRow(userid, xid) + return scanxonk(row) +} + func getbonk(userid int64, xid string) *Honk { - h := new(Honk) - var dt, aud, onts string row := stmtOneBonk.QueryRow(userid, xid) - err := row.Scan(&h.ID, &h.UserID, &h.Username, &h.What, &h.Honker, &h.Oonker, &h.XID, &h.RID, - &dt, &h.URL, &aud, &h.Noise, &h.Precis, &h.Convoy, &h.Whofore, &h.Flags, &onts) - if err != nil { - if err != sql.ErrNoRows { - log.Printf("error scanning xonk: %s", err) - } - return nil - } - h.Date, _ = time.Parse(dbtimeformat, dt) - h.Audience = strings.Split(aud, " ") - h.Public = !keepitquiet(h.Audience) - if len(onts) > 0 { - h.Onts = strings.Split(onts, " ") - } - return h + return scanxonk(row) } func getpublichonks() []*Honk {