From 227c05c3656ddaf55095747351d6a40e36bf76e8 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Mon, 10 Feb 2025 13:54:48 -0800 Subject: [PATCH] Fix channel unread count missing tts'd items --- core/channel.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/channel.go b/core/channel.go index 61169c8..73d5a0a 100644 --- a/core/channel.go +++ b/core/channel.go @@ -1,5 +1,7 @@ package core +import "time" + func AddSourceToChannel(db DB, channel string, source string) error { _, err := db.Exec(` insert into channels (name, source) @@ -41,12 +43,16 @@ func GetSourcesInChannel(db DB) (map[string][]string, error) { } func GetChannelsAndActiveCounts(db DB) (map[string]int, error) { + now := int(time.Now().Unix()) // TODO pass this value in rows, err := db.Query(` select c.name, count(i.id) as count from channels c - left outer join items i on c.source = i.source and i.active = 1 + left outer join items i + on c.source = i.source + and i.active <> 0 + and (i.tts = 0 or i.created + i.tts < ?) group by c.name - `) + `, now) if err != nil { return nil, err }