should delete old pubkeys after a while and refresh
This commit is contained in:
parent
944b58b197
commit
41a9cf5f6f
|
@ -1096,7 +1096,7 @@ var stmtFindFile, stmtGetFileData, stmtSaveFileData, stmtSaveFile *sql.Stmt
|
||||||
var stmtCheckFileData *sql.Stmt
|
var stmtCheckFileData *sql.Stmt
|
||||||
var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover, stmtOneHonker *sql.Stmt
|
var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover, stmtOneHonker *sql.Stmt
|
||||||
var stmtUntagged, stmtDeleteHonk, stmtDeleteDonks, stmtDeleteOnts, stmtSaveZonker *sql.Stmt
|
var stmtUntagged, stmtDeleteHonk, stmtDeleteDonks, stmtDeleteOnts, stmtSaveZonker *sql.Stmt
|
||||||
var stmtGetZonkers, stmtRecentHonkers, stmtGetXonker, stmtSaveXonker, stmtDeleteXonker *sql.Stmt
|
var stmtGetZonkers, stmtRecentHonkers, stmtGetXonker, stmtSaveXonker, stmtDeleteXonker, stmtDeleteOldXonkers *sql.Stmt
|
||||||
var stmtAllOnts, stmtSaveOnt, stmtUpdateFlags, stmtClearFlags *sql.Stmt
|
var stmtAllOnts, stmtSaveOnt, stmtUpdateFlags, stmtClearFlags *sql.Stmt
|
||||||
var stmtHonksForUserFirstClass *sql.Stmt
|
var stmtHonksForUserFirstClass *sql.Stmt
|
||||||
var stmtSaveMeta, stmtDeleteAllMeta, stmtDeleteOneMeta, stmtDeleteSomeMeta, stmtUpdateHonk *sql.Stmt
|
var stmtSaveMeta, stmtDeleteAllMeta, stmtDeleteOneMeta, stmtDeleteSomeMeta, stmtUpdateHonk *sql.Stmt
|
||||||
|
@ -1176,6 +1176,7 @@ func prepareStatements(db *sql.DB) {
|
||||||
stmtGetXonker = preparetodie(db, "select info from xonkers where name = ? and flavor = ?")
|
stmtGetXonker = preparetodie(db, "select info from xonkers where name = ? and flavor = ?")
|
||||||
stmtSaveXonker = preparetodie(db, "insert into xonkers (name, info, flavor, dt) values (?, ?, ?, ?)")
|
stmtSaveXonker = preparetodie(db, "insert into xonkers (name, info, flavor, dt) values (?, ?, ?, ?)")
|
||||||
stmtDeleteXonker = preparetodie(db, "delete from xonkers where name = ? and flavor = ? and dt < ?")
|
stmtDeleteXonker = preparetodie(db, "delete from xonkers where name = ? and flavor = ? and dt < ?")
|
||||||
|
stmtDeleteOldXonkers = preparetodie(db, "delete from xonkers where flavor = ? and dt < ?")
|
||||||
stmtRecentHonkers = preparetodie(db, "select distinct(honker) from honks where userid = ? and honker not in (select xid from honkers where userid = ? and flavor = 'sub') order by honkid desc limit 100")
|
stmtRecentHonkers = preparetodie(db, "select distinct(honker) from honks where userid = ? and honker not in (select xid from honkers where userid = ? and flavor = 'sub') order by honkid desc limit 100")
|
||||||
stmtUpdateFlags = preparetodie(db, "update honks set flags = flags | ? where honkid = ?")
|
stmtUpdateFlags = preparetodie(db, "update honks set flags = flags | ? where honkid = ?")
|
||||||
stmtClearFlags = preparetodie(db, "update honks set flags = flags & ~ ? where honkid = ?")
|
stmtClearFlags = preparetodie(db, "update honks set flags = flags & ~ ? where honkid = ?")
|
||||||
|
|
5
web.go
5
web.go
|
@ -2378,6 +2378,11 @@ var preservehooks []func()
|
||||||
|
|
||||||
func bgmonitor() {
|
func bgmonitor() {
|
||||||
for {
|
for {
|
||||||
|
when := time.Now().Add(-3 * 24 * time.Hour).UTC().Format(dbtimeformat)
|
||||||
|
_, err := stmtDeleteOldXonkers.Exec("pubkey", when)
|
||||||
|
if err != nil {
|
||||||
|
elog.Printf("error deleting old xonkers: %s", err)
|
||||||
|
}
|
||||||
time.Sleep(50 * time.Minute)
|
time.Sleep(50 * time.Minute)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue