use a flag for the untagged honks
This commit is contained in:
parent
209a7f0b4f
commit
c20f7e7eff
|
@ -683,7 +683,7 @@ var stmtHonksBySearch, stmtHonksByHonker, stmtSaveHonk, stmtUserByName, stmtUser
|
|||
var stmtEventHonks, stmtOneBonk, stmtFindZonk, stmtFindXonk, stmtSaveDonk *sql.Stmt
|
||||
var stmtFindFile, stmtGetFileData, stmtSaveFileData, stmtSaveFile *sql.Stmt
|
||||
var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover, stmtOneHonker *sql.Stmt
|
||||
var stmtDesubbed, stmtDeleteHonk, stmtDeleteDonks, stmtDeleteOnts, stmtSaveZonker *sql.Stmt
|
||||
var stmtUntagged, stmtDeleteHonk, stmtDeleteDonks, stmtDeleteOnts, stmtSaveZonker *sql.Stmt
|
||||
var stmtGetZonkers, stmtRecentHonkers, stmtGetXonker, stmtSaveXonker, stmtDeleteXonker *sql.Stmt
|
||||
var stmtAllOnts, stmtSaveOnt, stmtUpdateFlags, stmtClearFlags *sql.Stmt
|
||||
var stmtHonksForUserFirstClass, stmtSaveMeta, stmtDeleteMeta, stmtUpdateHonk *sql.Stmt
|
||||
|
@ -749,7 +749,7 @@ func prepareStatements(db *sql.DB) {
|
|||
stmtGetDoovers = preparetodie(db, "select dooverid, dt from doovers")
|
||||
stmtLoadDoover = preparetodie(db, "select tries, userid, rcpt, msg from doovers where dooverid = ?")
|
||||
stmtZapDoover = preparetodie(db, "delete from doovers where dooverid = ?")
|
||||
stmtDesubbed = preparetodie(db, "select name from zonkers where userid = ? and wherefore = 'desub'")
|
||||
stmtUntagged = preparetodie(db, "select xid, rid, flags from (select honkid, xid, rid, flags from honks where userid = ? order by honkid desc limit 2000) order by honkid asc")
|
||||
stmtFindZonk = preparetodie(db, "select zonkerid from zonkers where userid = ? and name = ? and wherefore = 'zonk'")
|
||||
stmtGetZonkers = preparetodie(db, "select zonkerid, name, wherefore from zonkers where userid = ? and wherefore <> 'zonk'")
|
||||
stmtSaveZonker = preparetodie(db, "insert into zonkers (userid, name, wherefore) values (?, ?, ?)")
|
||||
|
|
29
hfcs.go
29
hfcs.go
|
@ -302,30 +302,35 @@ func unsee(userid int64, h *Honk) {
|
|||
}
|
||||
}
|
||||
|
||||
var desubbed = cache.New(cache.Options{Filler: func(userid int64) (map[string]bool, bool) {
|
||||
rows, err := stmtDesubbed.Query(userid)
|
||||
var untagged = cache.New(cache.Options{Filler: func(userid int64) (map[string]bool, bool) {
|
||||
rows, err := stmtUntagged.Query(userid)
|
||||
if err != nil {
|
||||
log.Printf("error query desubbed: %s", err)
|
||||
log.Printf("error query untagged: %s", err)
|
||||
return nil, false
|
||||
}
|
||||
defer rows.Close()
|
||||
m := make(map[string]bool)
|
||||
bad := make(map[string]bool)
|
||||
for rows.Next() {
|
||||
var xid string
|
||||
err = rows.Scan(&xid)
|
||||
var xid, rid string
|
||||
var flags int64
|
||||
err = rows.Scan(&xid, &rid, &flags)
|
||||
if err != nil {
|
||||
log.Printf("error scanning desub: %s", err)
|
||||
log.Printf("error scanning untag: %s", err)
|
||||
continue
|
||||
}
|
||||
log.Printf("bad parent: %s", xid)
|
||||
m[xid] = true
|
||||
if flags&flagIsUntagged != 0 {
|
||||
bad[xid] = true
|
||||
}
|
||||
if bad[rid] {
|
||||
bad[xid] = true
|
||||
}
|
||||
}
|
||||
return m, true
|
||||
return bad, true
|
||||
}})
|
||||
|
||||
func osmosis(honks []*Honk, userid int64, withfilt bool) []*Honk {
|
||||
var badparents map[string]bool
|
||||
desubbed.GetAndLock(userid, &badparents)
|
||||
untagged.GetAndLock(userid, &badparents)
|
||||
j := 0
|
||||
reversehonks(honks)
|
||||
for _, h := range honks {
|
||||
|
@ -336,7 +341,7 @@ func osmosis(honks []*Honk, userid int64, withfilt bool) []*Honk {
|
|||
honks[j] = h
|
||||
j++
|
||||
}
|
||||
desubbed.Unlock()
|
||||
untagged.Unlock()
|
||||
honks = honks[0:j]
|
||||
reversehonks(honks)
|
||||
if !withfilt {
|
||||
|
|
11
honk.go
11
honk.go
|
@ -91,9 +91,10 @@ type OldRevision struct {
|
|||
}
|
||||
|
||||
const (
|
||||
flagIsAcked = 1
|
||||
flagIsBonked = 2
|
||||
flagIsSaved = 4
|
||||
flagIsAcked = 1
|
||||
flagIsBonked = 2
|
||||
flagIsSaved = 4
|
||||
flagIsUntagged = 8
|
||||
)
|
||||
|
||||
func (honk *Honk) IsAcked() bool {
|
||||
|
@ -108,6 +109,10 @@ func (honk *Honk) IsSaved() bool {
|
|||
return honk.Flags&flagIsSaved != 0
|
||||
}
|
||||
|
||||
func (honk *Honk) IsUntagged() bool {
|
||||
return honk.Flags&flagIsUntagged != 0
|
||||
}
|
||||
|
||||
type Donk struct {
|
||||
FileID int64
|
||||
XID string
|
||||
|
|
15
web.go
15
web.go
|
@ -1107,6 +1107,18 @@ func zonkit(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
if wherefore == "untag" {
|
||||
xonk := getxonk(userinfo.UserID, what)
|
||||
if xonk != nil {
|
||||
_, err := stmtUpdateFlags.Exec(flagIsUntagged, xonk.ID)
|
||||
if err != nil {
|
||||
log.Printf("error untagging: %s", err)
|
||||
}
|
||||
}
|
||||
untagged.Clear(userinfo.UserID)
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("zonking %s %s", wherefore, what)
|
||||
if wherefore == "zonk" {
|
||||
xonk := getxonk(userinfo.UserID, what)
|
||||
|
@ -1122,9 +1134,6 @@ func zonkit(w http.ResponseWriter, r *http.Request) {
|
|||
log.Printf("error saving zonker: %s", err)
|
||||
return
|
||||
}
|
||||
if wherefore == "desub" {
|
||||
desubbed.Clear(userinfo.UserID)
|
||||
}
|
||||
}
|
||||
|
||||
func edithonkpage(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
Loading…
Reference in New Issue