all repos — honk @ 0734ed4d3c7aa5ceaddeceb4f659364c5a8a7534

my fork of honk

de-hardcode time duration for honk display

by zev
Anirudh Oppiliappan x@icyphox.sh
Sun, 19 Mar 2023 09:33:58 +0200
commit

0734ed4d3c7aa5ceaddeceb4f659364c5a8a7534

parent

e388e597c55b4504a709ebf83cd8440edb850d1c

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

jump to
M database.godatabase.go

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

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

@@ -186,7 +188,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) }

@@ -222,7 +224,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 {

@@ -232,18 +234,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) return getsomehonks(rows, err) }