refresh pages using internal honkid which makes query much faster

This commit is contained in:
Ted Unangst 2019-10-20 14:36:55 -04:00
parent 0a262dbc96
commit c0d7cee48d
6 changed files with 67 additions and 73 deletions

View File

@ -1153,7 +1153,7 @@ var oldjonks = cache.New(cache.Options{Filler: func(xid string) ([]byte, bool) {
return nil, true return nil, true
} }
user, _ := butwhatabout(honk.Username) user, _ := butwhatabout(honk.Username)
rawhonks := gethonksbyconvoy(honk.UserID, honk.Convoy) rawhonks := gethonksbyconvoy(honk.UserID, honk.Convoy, 0)
reversehonks(rawhonks) reversehonks(rawhonks)
for _, h := range rawhonks { for _, h := range rawhonks {
if h.RID == honk.XID && h.Public && (h.Whofore == 2 || h.IsAcked()) { if h.RID == honk.XID && h.Public && (h.Whofore == 2 || h.IsAcked()) {

View File

@ -150,53 +150,53 @@ func geteventhonks(userid int64) []*Honk {
reversehonks(honks) reversehonks(honks)
return honks return honks
} }
func gethonksbyuser(name string, includeprivate bool) []*Honk { func gethonksbyuser(name string, includeprivate bool, wanted int64) []*Honk {
dt := time.Now().UTC().Add(-7 * 24 * time.Hour).Format(dbtimeformat) dt := time.Now().UTC().Add(-7 * 24 * time.Hour).Format(dbtimeformat)
whofore := 2 whofore := 2
if includeprivate { if includeprivate {
whofore = 3 whofore = 3
} }
rows, err := stmtUserHonks.Query(whofore, name, dt) rows, err := stmtUserHonks.Query(wanted, whofore, name, dt)
return getsomehonks(rows, err) return getsomehonks(rows, err)
} }
func gethonksforuser(userid int64) []*Honk { func gethonksforuser(userid int64, wanted int64) []*Honk {
dt := time.Now().UTC().Add(-7 * 24 * time.Hour).Format(dbtimeformat) dt := time.Now().UTC().Add(-7 * 24 * time.Hour).Format(dbtimeformat)
rows, err := stmtHonksForUser.Query(userid, dt, userid, userid) rows, err := stmtHonksForUser.Query(wanted, userid, dt, userid, userid)
return getsomehonks(rows, err) return getsomehonks(rows, err)
} }
func gethonksforuserfirstclass(userid int64) []*Honk { func gethonksforuserfirstclass(userid int64, wanted int64) []*Honk {
dt := time.Now().UTC().Add(-7 * 24 * time.Hour).Format(dbtimeformat) dt := time.Now().UTC().Add(-7 * 24 * time.Hour).Format(dbtimeformat)
rows, err := stmtHonksForUserFirstClass.Query(userid, dt, userid, userid) rows, err := stmtHonksForUserFirstClass.Query(wanted, userid, dt, userid, userid)
return getsomehonks(rows, err) return getsomehonks(rows, err)
} }
func gethonksforme(userid int64) []*Honk { func gethonksforme(userid int64, wanted int64) []*Honk {
dt := time.Now().UTC().Add(-7 * 24 * time.Hour).Format(dbtimeformat) dt := time.Now().UTC().Add(-7 * 24 * time.Hour).Format(dbtimeformat)
rows, err := stmtHonksForMe.Query(userid, dt, userid) rows, err := stmtHonksForMe.Query(wanted, userid, dt, userid)
return getsomehonks(rows, err) return getsomehonks(rows, err)
} }
func getsavedhonks(userid int64) []*Honk { func getsavedhonks(userid int64, wanted int64) []*Honk {
rows, err := stmtHonksISaved.Query(userid) rows, err := stmtHonksISaved.Query(wanted, userid)
return getsomehonks(rows, err) return getsomehonks(rows, err)
} }
func gethonksbyhonker(userid int64, honker string) []*Honk { func gethonksbyhonker(userid int64, honker string, wanted int64) []*Honk {
rows, err := stmtHonksByHonker.Query(userid, honker, userid) rows, err := stmtHonksByHonker.Query(wanted, userid, honker, userid)
return getsomehonks(rows, err) return getsomehonks(rows, err)
} }
func gethonksbyxonker(userid int64, xonker string) []*Honk { func gethonksbyxonker(userid int64, xonker string, wanted int64) []*Honk {
rows, err := stmtHonksByXonker.Query(userid, xonker, xonker, userid) rows, err := stmtHonksByXonker.Query(wanted, userid, xonker, xonker, userid)
return getsomehonks(rows, err) return getsomehonks(rows, err)
} }
func gethonksbycombo(userid int64, combo string) []*Honk { func gethonksbycombo(userid int64, combo string, wanted int64) []*Honk {
combo = "% " + combo + " %" combo = "% " + combo + " %"
rows, err := stmtHonksByCombo.Query(userid, combo, userid) rows, err := stmtHonksByCombo.Query(wanted, userid, combo, userid)
return getsomehonks(rows, err) return getsomehonks(rows, err)
} }
func gethonksbyconvoy(userid int64, convoy string) []*Honk { func gethonksbyconvoy(userid int64, convoy string, wanted int64) []*Honk {
rows, err := stmtHonksByConvoy.Query(userid, userid, convoy) rows, err := stmtHonksByConvoy.Query(wanted, userid, userid, convoy)
honks := getsomehonks(rows, err) honks := getsomehonks(rows, err)
return honks return honks
} }
func gethonksbysearch(userid int64, q string) []*Honk { func gethonksbysearch(userid int64, q string, wanted int64) []*Honk {
honker := "" honker := ""
withhonker := 0 withhonker := 0
site := "" site := ""
@ -225,12 +225,12 @@ func gethonksbysearch(userid int64, q string) []*Honk {
q += t q += t
} }
q += "%" q += "%"
rows, err := stmtHonksBySearch.Query(userid, withsite, site, withhonker, honker, honker, q, userid) rows, err := stmtHonksBySearch.Query(wanted, userid, withsite, site, withhonker, honker, honker, q, userid)
honks := getsomehonks(rows, err) honks := getsomehonks(rows, err)
return honks return honks
} }
func gethonksbyontology(userid int64, name string) []*Honk { func gethonksbyontology(userid int64, name string, wanted int64) []*Honk {
rows, err := stmtHonksByOntology.Query(name, userid, userid) rows, err := stmtHonksByOntology.Query(wanted, name, userid, userid)
honks := getsomehonks(rows, err) honks := getsomehonks(rows, err)
return honks return honks
} }
@ -667,18 +667,18 @@ func prepareStatements(db *sql.DB) {
stmtOneBonk = preparetodie(db, selecthonks+"where honks.userid = ? and xid = ? and what = 'bonk' and whofore = 2") stmtOneBonk = preparetodie(db, selecthonks+"where honks.userid = ? and xid = ? and what = 'bonk' and whofore = 2")
stmtPublicHonks = preparetodie(db, selecthonks+"where whofore = 2 and dt > ?"+limit) stmtPublicHonks = preparetodie(db, selecthonks+"where whofore = 2 and dt > ?"+limit)
stmtEventHonks = preparetodie(db, selecthonks+"where (whofore = 2 or honks.userid = ?) and what = 'event'"+limit) stmtEventHonks = preparetodie(db, selecthonks+"where (whofore = 2 or honks.userid = ?) and what = 'event'"+limit)
stmtUserHonks = preparetodie(db, selecthonks+"where (whofore = 2 or whofore = ?) and username = ? and dt > ?"+limit) stmtUserHonks = preparetodie(db, selecthonks+"where honks.honkid > ? and (whofore = 2 or whofore = ?) and username = ? and dt > ?"+limit)
myhonkers := " and honker in (select xid from honkers where userid = ? and (flavor = 'sub' or flavor = 'peep' or flavor = 'presub') and combos not like '% - %')" myhonkers := " and honker in (select xid from honkers where userid = ? and (flavor = 'sub' or flavor = 'peep' or flavor = 'presub') and combos not like '% - %')"
stmtHonksForUser = preparetodie(db, selecthonks+"where honks.userid = ? and dt > ?"+myhonkers+butnotthose+limit) stmtHonksForUser = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and dt > ?"+myhonkers+butnotthose+limit)
stmtHonksForUserFirstClass = preparetodie(db, selecthonks+"where honks.userid = ? and dt > ? and (what <> 'tonk')"+myhonkers+butnotthose+limit) stmtHonksForUserFirstClass = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and dt > ? and (what <> 'tonk')"+myhonkers+butnotthose+limit)
stmtHonksForMe = preparetodie(db, selecthonks+"where honks.userid = ? and dt > ? and whofore = 1"+butnotthose+limit) stmtHonksForMe = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and dt > ? and whofore = 1"+butnotthose+limit)
stmtHonksISaved = preparetodie(db, selecthonks+"where honks.userid = ? and flags & 4 order by honks.honkid desc") stmtHonksISaved = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and flags & 4 order by honks.honkid desc")
stmtHonksByHonker = preparetodie(db, selecthonks+"join honkers on (honkers.xid = honks.honker or honkers.xid = honks.oonker) where honks.userid = ? and honkers.name = ?"+butnotthose+limit) stmtHonksByHonker = preparetodie(db, selecthonks+"join honkers on (honkers.xid = honks.honker or honkers.xid = honks.oonker) where honks.honkid > ? and honks.userid = ? and honkers.name = ?"+butnotthose+limit)
stmtHonksByXonker = preparetodie(db, selecthonks+" where honks.userid = ? and (honker = ? or oonker = ?)"+butnotthose+limit) stmtHonksByXonker = preparetodie(db, selecthonks+" where honks.honkid > ? and honks.userid = ? and (honker = ? or oonker = ?)"+butnotthose+limit)
stmtHonksByCombo = preparetodie(db, selecthonks+"join honkers on honkers.xid = honks.honker where honks.userid = ? and honkers.combos like ?"+butnotthose+limit) stmtHonksByCombo = preparetodie(db, selecthonks+"join honkers on honkers.xid = honks.honker where honks.honkid > ? and honks.userid = ? and honkers.combos like ?"+butnotthose+limit)
stmtHonksBySearch = preparetodie(db, selecthonks+"where honks.userid = ? and (? = 0 or xid like ?) and (? = 0 or honks.honker = ? or honks.oonker = ?) and noise like ?"+butnotthose+limit) stmtHonksBySearch = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and (? = 0 or xid like ?) and (? = 0 or honks.honker = ? or honks.oonker = ?) and noise like ?"+butnotthose+limit)
stmtHonksByConvoy = preparetodie(db, selecthonks+"where (honks.userid = ? or (? = -1 and whofore = 2)) and convoy = ?"+limit) 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 onts.ontology = ? and (honks.userid = ? or (? = -1 and honks.whofore = 2))"+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 (?, ?, ?)") stmtSaveMeta = preparetodie(db, "insert into honkmeta (honkid, genus, json) values (?, ?, ?)")
stmtDeleteMeta = preparetodie(db, "delete from honkmeta where honkid = ? and genus <> ?") stmtDeleteMeta = preparetodie(db, "delete from honkmeta where honkid = ? and genus <> ?")

View File

@ -1,4 +1,4 @@
<div>{{ .TopXID }}</div> <div>{{ .TopHID }}</div>
{{ $BonkCSRF := .HonkCSRF }} {{ $BonkCSRF := .HonkCSRF }}
<div><p>{{ .ServerMessage }}</div> <div><p>{{ .ServerMessage }}</div>
<div> <div>

View File

@ -30,8 +30,8 @@
var csrftoken = {{ .HonkCSRF }} var csrftoken = {{ .HonkCSRF }}
var honksforpage = { } var honksforpage = { }
var curpagestate = { name: "{{ .PageName }}", arg : "{{ .PageArg }}" } var curpagestate = { name: "{{ .PageName }}", arg : "{{ .PageArg }}" }
var topxid = { } var tophid = { }
topxid[curpagestate.name + ":" + curpagestate.arg] = "{{ .TopXID }}" tophid[curpagestate.name + ":" + curpagestate.arg] = "{{ .TopHID }}"
var servermsgs = { } var servermsgs = { }
servermsgs[curpagestate.name + ":" + curpagestate.arg] = "{{ .ServerMessage }}" servermsgs[curpagestate.name + ":" + curpagestate.arg] = "{{ .ServerMessage }}"

View File

@ -65,7 +65,7 @@ function flogit(el, how, xid) {
function fillinhonks(xhr) { function fillinhonks(xhr) {
var doc = xhr.responseXML var doc = xhr.responseXML
var stash = curpagestate.name + ":" + curpagestate.arg var stash = curpagestate.name + ":" + curpagestate.arg
topxid[stash] = doc.children[0].children[1].children[0].innerText tophid[stash] = doc.children[0].children[1].children[0].innerText
var srvmsg = doc.children[0].children[1].children[1] var srvmsg = doc.children[0].children[1].children[1]
var honks = doc.children[0].children[1].children[2].children var honks = doc.children[0].children[1].children[2].children
@ -118,7 +118,7 @@ function refreshhonks(btn) {
btn.disabled = true btn.disabled = true
var args = hydrargs() var args = hydrargs()
var stash = curpagestate.name + ":" + curpagestate.arg var stash = curpagestate.name + ":" + curpagestate.arg
args["topxid"] = topxid[stash] args["tophid"] = tophid[stash]
get("/hydra?" + encode(args), function(xhr) { get("/hydra?" + encode(args), function(xhr) {
var lenhonks = fillinhonks(xhr) var lenhonks = fillinhonks(xhr)
btn.innerHTML = "refresh" btn.innerHTML = "refresh"

62
web.go
View File

@ -100,7 +100,7 @@ func homepage(w http.ResponseWriter, r *http.Request) {
case "/atme": case "/atme":
templinfo["PageName"] = "at me!" templinfo["PageName"] = "at me!"
templinfo["PageName"] = "atme" templinfo["PageName"] = "atme"
honks = gethonksforme(userid) honks = gethonksforme(userid, 0)
case "/events": case "/events":
templinfo["ServerMessage"] = "some recent and upcoming events" templinfo["ServerMessage"] = "some recent and upcoming events"
templinfo["PageName"] = "events" templinfo["PageName"] = "events"
@ -108,15 +108,15 @@ func homepage(w http.ResponseWriter, r *http.Request) {
honks = osmosis(honks, userid) honks = osmosis(honks, userid)
case "/first": case "/first":
templinfo["PageName"] = "first" templinfo["PageName"] = "first"
honks = gethonksforuser(userid) honks = gethonksforuser(userid, 0)
honks = osmosis(honks, userid) honks = osmosis(honks, userid)
case "/saved": case "/saved":
templinfo["ServerMessage"] = "saved honks" templinfo["ServerMessage"] = "saved honks"
templinfo["PageName"] = "saved" templinfo["PageName"] = "saved"
honks = getsavedhonks(userid) honks = getsavedhonks(userid, 0)
default: default:
templinfo["PageName"] = "home" templinfo["PageName"] = "home"
honks = gethonksforuser(userid) honks = gethonksforuser(userid, 0)
honks = osmosis(honks, userid) honks = osmosis(honks, userid)
} }
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r) templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
@ -156,7 +156,7 @@ func showrss(w http.ResponseWriter, r *http.Request) {
var honks []*Honk var honks []*Honk
if name != "" { if name != "" {
honks = gethonksbyuser(name, false) honks = gethonksbyuser(name, false, 0)
} else { } else {
honks = getpublichonks() honks = getpublichonks()
} }
@ -477,7 +477,7 @@ var oldoutbox = cache.New(cache.Options{Filler: func(name string) ([]byte, bool)
if err != nil { if err != nil {
return nil, false return nil, false
} }
honks := gethonksbyuser(name, false) honks := gethonksbyuser(name, false, 0)
if len(honks) > 20 { if len(honks) > 20 {
honks = honks[0:20] honks = honks[0:20]
} }
@ -570,7 +570,7 @@ func showuser(w http.ResponseWriter, r *http.Request) {
return return
} }
u := login.GetUserInfo(r) u := login.GetUserInfo(r)
honks := gethonksbyuser(name, u != nil && u.Username == name) honks := gethonksbyuser(name, u != nil && u.Username == name, 0)
templinfo := getInfo(r) templinfo := getInfo(r)
filt := htfilter.New() filt := htfilter.New()
templinfo["Name"] = user.Name templinfo["Name"] = user.Name
@ -588,9 +588,9 @@ func showhonker(w http.ResponseWriter, r *http.Request) {
var honks []*Honk var honks []*Honk
if name == "" { if name == "" {
name = r.FormValue("xid") name = r.FormValue("xid")
honks = gethonksbyxonker(u.UserID, name) honks = gethonksbyxonker(u.UserID, name, 0)
} else { } else {
honks = gethonksbyhonker(u.UserID, name) honks = gethonksbyhonker(u.UserID, name, 0)
} }
msg := templates.Sprintf(`honks by honker: <a href="%s" ref="noreferrer">%s</a>`, name, name) msg := templates.Sprintf(`honks by honker: <a href="%s" ref="noreferrer">%s</a>`, name, name)
templinfo := getInfo(r) templinfo := getInfo(r)
@ -604,7 +604,7 @@ func showhonker(w http.ResponseWriter, r *http.Request) {
func showcombo(w http.ResponseWriter, r *http.Request) { func showcombo(w http.ResponseWriter, r *http.Request) {
name := mux.Vars(r)["name"] name := mux.Vars(r)["name"]
u := login.GetUserInfo(r) u := login.GetUserInfo(r)
honks := gethonksbycombo(u.UserID, name) honks := gethonksbycombo(u.UserID, name, 0)
honks = osmosis(honks, u.UserID) honks = osmosis(honks, u.UserID)
templinfo := getInfo(r) templinfo := getInfo(r)
templinfo["PageName"] = "combo" templinfo["PageName"] = "combo"
@ -616,10 +616,10 @@ func showcombo(w http.ResponseWriter, r *http.Request) {
func showconvoy(w http.ResponseWriter, r *http.Request) { func showconvoy(w http.ResponseWriter, r *http.Request) {
c := r.FormValue("c") c := r.FormValue("c")
u := login.GetUserInfo(r) u := login.GetUserInfo(r)
honks := gethonksbyconvoy(u.UserID, c) honks := gethonksbyconvoy(u.UserID, c, 0)
templinfo := getInfo(r) templinfo := getInfo(r)
if len(honks) > 0 { if len(honks) > 0 {
templinfo["TopXID"] = honks[0].XID templinfo["TopHID"] = honks[0].ID
} }
reversehonks(honks) reversehonks(honks)
templinfo["PageName"] = "convoy" templinfo["PageName"] = "convoy"
@ -631,7 +631,7 @@ func showconvoy(w http.ResponseWriter, r *http.Request) {
func showsearch(w http.ResponseWriter, r *http.Request) { func showsearch(w http.ResponseWriter, r *http.Request) {
q := r.FormValue("q") q := r.FormValue("q")
u := login.GetUserInfo(r) u := login.GetUserInfo(r)
honks := gethonksbysearch(u.UserID, q) honks := gethonksbysearch(u.UserID, q, 0)
templinfo := getInfo(r) templinfo := getInfo(r)
templinfo["PageName"] = "search" templinfo["PageName"] = "search"
templinfo["PageArg"] = q templinfo["PageArg"] = q
@ -646,7 +646,7 @@ func showontology(w http.ResponseWriter, r *http.Request) {
if u != nil { if u != nil {
userid = u.UserID userid = u.UserID
} }
honks := gethonksbyontology(userid, "#"+name) honks := gethonksbyontology(userid, "#"+name, 0)
templinfo := getInfo(r) templinfo := getInfo(r)
templinfo["ServerMessage"] = "honks by ontology: " + name templinfo["ServerMessage"] = "honks by ontology: " + name
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r) templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
@ -742,7 +742,7 @@ func showhonk(w http.ResponseWriter, r *http.Request) {
honkpage(w, u, []*Honk{honk}, templinfo) honkpage(w, u, []*Honk{honk}, templinfo)
return return
} }
rawhonks := gethonksbyconvoy(honk.UserID, honk.Convoy) rawhonks := gethonksbyconvoy(honk.UserID, honk.Convoy, 0)
reversehonks(rawhonks) reversehonks(rawhonks)
var honks []*Honk var honks []*Honk
for _, h := range rawhonks { for _, h := range rawhonks {
@ -767,8 +767,8 @@ func honkpage(w http.ResponseWriter, u *login.UserInfo, honks []*Honk, templinfo
} }
reverbolate(userid, honks) reverbolate(userid, honks)
templinfo["Honks"] = honks templinfo["Honks"] = honks
if templinfo["TopXID"] == nil && len(honks) > 0 { if templinfo["TopHID"] == nil && len(honks) > 0 {
templinfo["TopXID"] = honks[0].XID templinfo["TopHID"] = honks[0].ID
} }
err := readviews.Execute(w, "honkpage.html", templinfo) err := readviews.Execute(w, "honkpage.html", templinfo)
if err != nil { if err != nil {
@ -1632,54 +1632,48 @@ func webhydra(w http.ResponseWriter, r *http.Request) {
templinfo := getInfo(r) templinfo := getInfo(r)
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r) templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
page := r.FormValue("page") page := r.FormValue("page")
wanted, _ := strconv.ParseInt(r.FormValue("tophid"), 10, 0)
var honks []*Honk var honks []*Honk
switch page { switch page {
case "atme": case "atme":
honks = gethonksforme(userid) honks = gethonksforme(userid, wanted)
templinfo["ServerMessage"] = "at me!" templinfo["ServerMessage"] = "at me!"
case "home": case "home":
honks = gethonksforuser(userid) honks = gethonksforuser(userid, wanted)
honks = osmosis(honks, userid) honks = osmosis(honks, userid)
templinfo["ServerMessage"] = serverMsg templinfo["ServerMessage"] = serverMsg
case "first": case "first":
honks = gethonksforuserfirstclass(userid) honks = gethonksforuserfirstclass(userid, wanted)
honks = osmosis(honks, userid) honks = osmosis(honks, userid)
templinfo["ServerMessage"] = "first class only" templinfo["ServerMessage"] = "first class only"
case "saved": case "saved":
honks = getsavedhonks(userid) honks = getsavedhonks(userid, wanted)
templinfo["PageName"] = "saved" templinfo["PageName"] = "saved"
templinfo["ServerMessage"] = "saved honks" templinfo["ServerMessage"] = "saved honks"
case "combo": case "combo":
c := r.FormValue("c") c := r.FormValue("c")
honks = gethonksbycombo(userid, c) honks = gethonksbycombo(userid, c, wanted)
honks = osmosis(honks, userid) honks = osmosis(honks, userid)
templinfo["ServerMessage"] = "honks by combo: " + c templinfo["ServerMessage"] = "honks by combo: " + c
case "convoy": case "convoy":
c := r.FormValue("c") c := r.FormValue("c")
honks = gethonksbyconvoy(userid, c) honks = gethonksbyconvoy(userid, c, wanted)
templinfo["ServerMessage"] = "honks in convoy: " + c templinfo["ServerMessage"] = "honks in convoy: " + c
case "honker": case "honker":
xid := r.FormValue("xid") xid := r.FormValue("xid")
if strings.IndexByte(xid, '@') != -1 { if strings.IndexByte(xid, '@') != -1 {
xid = gofish(xid) xid = gofish(xid)
} }
honks = gethonksbyxonker(userid, xid) honks = gethonksbyxonker(userid, xid, wanted)
msg := templates.Sprintf(`honks by honker: <a href="%s" ref="noreferrer">%s</a>`, xid, xid) msg := templates.Sprintf(`honks by honker: <a href="%s" ref="noreferrer">%s</a>`, xid, xid)
templinfo["ServerMessage"] = msg templinfo["ServerMessage"] = msg
default: default:
http.NotFound(w, r) http.NotFound(w, r)
} }
if len(honks) > 0 { if len(honks) > 0 {
templinfo["TopXID"] = honks[0].XID templinfo["TopHID"] = honks[0].ID
}
if topxid := r.FormValue("topxid"); topxid != "" {
for i, h := range honks {
if h.XID == topxid {
honks = honks[0:i]
break
}
}
log.Printf("topxid %d frags", len(honks))
} }
reverbolate(userid, honks) reverbolate(userid, honks)
templinfo["Honks"] = honks templinfo["Honks"] = honks