all repos — honk @ 8237a2780e9c07bacb11403db8ef964d16121853

my fork of honk

factor out 7 day honkwindow, from zev
Ted Unangst tedu@tedunangst.com
Mon, 28 Aug 2023 01:10:27 -0400
commit

8237a2780e9c07bacb11403db8ef964d16121853

parent

4f63731d669deebc5ed0db2862f699e662e6c3eb

1 files changed, 7 insertions(+), 5 deletions(-)

jump to
M database.godatabase.go

@@ -36,6 +36,8 @@ "humungus.tedunangst.com/r/webs/login"

"humungus.tedunangst.com/r/webs/mz" ) +var honkwindow time.Duration = 7 * 24 * time.Hour + //go:embed schema.sql var sqlSchema string

@@ -187,7 +189,7 @@ return scanhonk(row)

} func getpublichonks() []*Honk { - dt := time.Now().Add(-7 * 24 * time.Hour).UTC().Format(dbtimeformat) + dt := time.Now().Add(-honkwindow).UTC().Format(dbtimeformat) rows, err := stmtPublicHonks.Query(dt, 100) return getsomehonks(rows, err) }

@@ -223,7 +225,7 @@ reversehonks(honks)

return honks } func gethonksbyuser(name string, includeprivate bool, wanted int64) []*Honk { - dt := time.Now().Add(-7 * 24 * time.Hour).UTC().Format(dbtimeformat) + dt := time.Now().Add(-honkwindow).UTC().Format(dbtimeformat) limit := 50 whofore := 2 if includeprivate {

@@ -233,18 +235,18 @@ rows, err := stmtUserHonks.Query(wanted, whofore, name, dt, limit)

return getsomehonks(rows, err) } func gethonksforuser(userid int64, wanted int64) []*Honk { - dt := time.Now().Add(-7 * 24 * time.Hour).UTC().Format(dbtimeformat) + dt := time.Now().Add(-honkwindow).UTC().Format(dbtimeformat) rows, err := stmtHonksForUser.Query(wanted, userid, dt, userid, userid) return getsomehonks(rows, err) } func gethonksforuserfirstclass(userid int64, wanted int64) []*Honk { - dt := time.Now().Add(-7 * 24 * time.Hour).UTC().Format(dbtimeformat) + dt := time.Now().Add(-honkwindow).UTC().Format(dbtimeformat) rows, err := stmtHonksForUserFirstClass.Query(wanted, userid, dt, userid, userid) return getsomehonks(rows, err) } func gethonksforme(userid int64, wanted int64) []*Honk { - dt := time.Now().Add(-7 * 24 * time.Hour).UTC().Format(dbtimeformat) + dt := time.Now().Add(-honkwindow).UTC().Format(dbtimeformat) rows, err := stmtHonksForMe.Query(wanted, userid, dt, userid, 250) return getsomehonks(rows, err) }