From d272b8110a456866cf1ed394fd1ce08dac10af46 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Thu, 10 Feb 2022 20:30:39 -0500 Subject: [PATCH] pull in even longer ago long ago honks --- database.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/database.go b/database.go index be4d738..e144ffb 100644 --- a/database.go +++ b/database.go @@ -243,12 +243,16 @@ func gethonksforme(userid int64, wanted int64) []*Honk { } func gethonksfromlongago(userid int64, wanted int64) []*Honk { now := time.Now().UTC() - now = time.Date(now.Year()-1, now.Month(), now.Day(), now.Hour(), now.Minute(), - now.Second(), 0, now.Location()) - dt1 := now.Add(-36 * time.Hour).Format(dbtimeformat) - dt2 := now.Add(12 * time.Hour).Format(dbtimeformat) - rows, err := stmtHonksFromLongAgo.Query(wanted, userid, dt1, dt2, userid) - return getsomehonks(rows, err) + var honks []*Honk + for i := 1; i <= 3; i++ { + dt := time.Date(now.Year()-i, now.Month(), now.Day(), now.Hour(), now.Minute(), + now.Second(), 0, now.Location()) + dt1 := dt.Add(-36 * time.Hour).Format(dbtimeformat) + dt2 := dt.Add(12 * time.Hour).Format(dbtimeformat) + rows, err := stmtHonksFromLongAgo.Query(wanted, userid, dt1, dt2, userid) + honks = append(honks, getsomehonks(rows, err)...) + } + return honks } func getsavedhonks(userid int64, wanted int64) []*Honk { rows, err := stmtHonksISaved.Query(wanted, userid)