From 0a03f937ecce58ba47b364bc1a0d8ffc93e7593b Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Tue, 12 Nov 2019 01:43:16 -0500 Subject: [PATCH] reduce number of honks on some pages --- database.go | 15 +++++++++------ web.go | 3 --- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/database.go b/database.go index fa8afc2..3706cde 100644 --- a/database.go +++ b/database.go @@ -166,11 +166,11 @@ func getbonk(userid int64, xid string) *Honk { func getpublichonks() []*Honk { dt := time.Now().UTC().Add(-7 * 24 * time.Hour).Format(dbtimeformat) - rows, err := stmtPublicHonks.Query(dt) + rows, err := stmtPublicHonks.Query(dt, 25) return getsomehonks(rows, err) } func geteventhonks(userid int64) []*Honk { - rows, err := stmtEventHonks.Query(userid) + rows, err := stmtEventHonks.Query(userid, 25) honks := getsomehonks(rows, err) sort.Slice(honks, func(i, j int) bool { var t1, t2 time.Time @@ -199,10 +199,12 @@ func geteventhonks(userid int64) []*Honk { func gethonksbyuser(name string, includeprivate bool, wanted int64) []*Honk { dt := time.Now().UTC().Add(-7 * 24 * time.Hour).Format(dbtimeformat) whofore := 2 + limit := 25 if includeprivate { whofore = 3 + limit = 50 } - rows, err := stmtUserHonks.Query(wanted, whofore, name, dt) + rows, err := stmtUserHonks.Query(wanted, whofore, name, dt, limit) return getsomehonks(rows, err) } func gethonksforuser(userid int64, wanted int64) []*Honk { @@ -712,13 +714,14 @@ func prepareStatements(db *sql.DB) { selecthonks := "select honks.honkid, honks.userid, username, what, honker, oonker, honks.xid, rid, dt, url, audience, noise, precis, format, convoy, whofore, flags from honks join users on honks.userid = users.userid " limit := " order by honks.honkid desc limit 250" + smalllimit := " order by honks.honkid desc limit ?" butnotthose := " and convoy not in (select name from zonkers where userid = ? and wherefore = 'zonvoy' order by zonkerid desc limit 100)" stmtOneXonk = preparetodie(db, selecthonks+"where honks.userid = ? and xid = ?") stmtAnyXonk = preparetodie(db, selecthonks+"where xid = ? order by honks.honkid asc") 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) - stmtEventHonks = preparetodie(db, selecthonks+"where (whofore = 2 or honks.userid = ?) and what = 'event'"+limit) - stmtUserHonks = preparetodie(db, selecthonks+"where honks.honkid > ? and (whofore = 2 or whofore = ?) and username = ? and dt > ?"+limit) + stmtPublicHonks = preparetodie(db, selecthonks+"where whofore = 2 and dt > ?"+smalllimit) + stmtEventHonks = preparetodie(db, selecthonks+"where (whofore = 2 or honks.userid = ?) and what = 'event'"+smalllimit) + stmtUserHonks = preparetodie(db, selecthonks+"where honks.honkid > ? and (whofore = 2 or whofore = ?) and username = ? and dt > ?"+smalllimit) 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.honkid > ? and honks.userid = ? and dt > ?"+myhonkers+butnotthose+limit) stmtHonksForUserFirstClass = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and dt > ? and (what <> 'tonk')"+myhonkers+butnotthose+limit) diff --git a/web.go b/web.go index 9ddbcb3..74c6fb0 100644 --- a/web.go +++ b/web.go @@ -161,9 +161,6 @@ func showrss(w http.ResponseWriter, r *http.Request) { } else { honks = getpublichonks() } - if len(honks) > 20 { - honks = honks[0:20] - } reverbolate(-1, honks) home := fmt.Sprintf("https://%s/", serverName)