From 3f7dcaad9e414f39d8b64e821583d0e0d5a30072 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sun, 19 Jul 2020 18:51:02 -0400 Subject: [PATCH] add a long ago link... --- database.go | 9 +++++++++ views/header.html | 3 ++- web.go | 13 +++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/database.go b/database.go index 9c98de3..130e4af 100644 --- a/database.go +++ b/database.go @@ -232,6 +232,13 @@ func gethonksforme(userid int64, wanted int64) []*Honk { rows, err := stmtHonksForMe.Query(wanted, userid, dt, userid) return getsomehonks(rows, err) } +func gethonksfromlongago(userid int64, wanted int64) []*Honk { + now := time.Now().UTC() + dt1 := now.Add(-367 * 24 * time.Hour).Format(dbtimeformat) + dt2 := now.Add(-364 * 24 * time.Hour).Format(dbtimeformat) + rows, err := stmtHonksFromLongAgo.Query(wanted, userid, dt1, dt2, userid) + return getsomehonks(rows, err) +} func getsavedhonks(userid int64, wanted int64) []*Honk { rows, err := stmtHonksISaved.Query(wanted, userid) return getsomehonks(rows, err) @@ -849,6 +856,7 @@ func cleanupdb(arg string) { var stmtHonkers, stmtDubbers, stmtNamedDubbers, stmtSaveHonker, stmtUpdateFlavor, stmtUpdateHonker *sql.Stmt var stmtAnyXonk, stmtOneXonk, stmtPublicHonks, stmtUserHonks, stmtHonksByCombo, stmtHonksByConvoy *sql.Stmt var stmtHonksByOntology, stmtHonksForUser, stmtHonksForMe, stmtSaveDub, stmtHonksByXonker *sql.Stmt +var stmtHonksFromLongAgo *sql.Stmt var stmtHonksByHonker, stmtSaveHonk, stmtUserByName, stmtUserByNumber *sql.Stmt var stmtEventHonks, stmtOneBonk, stmtFindZonk, stmtFindXonk, stmtSaveDonk *sql.Stmt var stmtFindFile, stmtGetFileData, stmtSaveFileData, stmtSaveFile *sql.Stmt @@ -893,6 +901,7 @@ func prepareStatements(db *sql.DB) { 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) stmtHonksForMe = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and dt > ? and whofore = 1"+butnotthose+limit) + stmtHonksFromLongAgo = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and dt < ? and dt > ? and whofore = 2"+butnotthose+limit) 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.honkid > ? and honks.userid = ? and honkers.name = ?"+butnotthose+limit) stmtHonksByXonker = preparetodie(db, selecthonks+" where honks.honkid > ? and honks.userid = ? and (honker = ? or oonker = ?)"+butnotthose+limit) diff --git a/views/header.html b/views/header.html index 3f07332..4212c94 100644 --- a/views/header.html +++ b/views/header.html @@ -34,15 +34,16 @@
  • chatter
  • tags
  • events +
  • long ago
  • saved
  • honkers
  • filters -
  • my honks
  • account
  • more stuff
      +
    • my honks
    • about
    • front
    • funzone diff --git a/web.go b/web.go index 5ae79c0..2525285 100644 --- a/web.go +++ b/web.go @@ -117,6 +117,11 @@ func homepage(w http.ResponseWriter, r *http.Request) { templinfo["PageName"] = "atme" honks = gethonksforme(userid, 0) honks = osmosis(honks, userid, false) + case "/longago": + templinfo["ServerMessage"] = "long ago and far away!" + templinfo["PageName"] = "longago" + honks = gethonksforme(userid, 0) + honks = osmosis(honks, userid, false) case "/events": templinfo["ServerMessage"] = "some recent and upcoming events" templinfo["PageName"] = "events" @@ -2236,6 +2241,10 @@ func webhydra(w http.ResponseWriter, r *http.Request) { honks = gethonksforme(userid, wanted) honks = osmosis(honks, userid, false) templinfo["ServerMessage"] = "at me!" + case "longago": + honks = gethonksfromlongago(userid, wanted) + honks = osmosis(honks, userid, false) + templinfo["ServerMessage"] = "from long ago" case "home": honks = gethonksforuser(userid, wanted) honks = osmosis(honks, userid, true) @@ -2329,6 +2338,9 @@ func apihandler(w http.ResponseWriter, r *http.Request) { case "atme": honks = gethonksforme(userid, wanted) honks = osmosis(honks, userid, false) + case "longago": + honks = gethonksfromlongago(userid, wanted) + honks = osmosis(honks, userid, false) case "home": honks = gethonksforuser(userid, wanted) honks = osmosis(honks, userid, true) @@ -2502,6 +2514,7 @@ func serve() { loggedin.HandleFunc("/funzone", showfunzone) loggedin.HandleFunc("/chpass", dochpass) loggedin.HandleFunc("/atme", homepage) + loggedin.HandleFunc("/longago", homepage) loggedin.HandleFunc("/hfcs", hfcspage) loggedin.HandleFunc("/xzone", xzone) loggedin.HandleFunc("/newhonk", newhonkpage)