Fix channel unread count missing tts'd items

This commit is contained in:
Tim Van Baak 2025-02-10 13:54:48 -08:00
parent 9703db8478
commit 227c05c365

View File

@ -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
}