Fix channel unread count missing tts'd items
This commit is contained in:
parent
9703db8478
commit
227c05c365
@ -1,5 +1,7 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
func AddSourceToChannel(db DB, channel string, source string) error {
|
func AddSourceToChannel(db DB, channel string, source string) error {
|
||||||
_, err := db.Exec(`
|
_, err := db.Exec(`
|
||||||
insert into channels (name, source)
|
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) {
|
func GetChannelsAndActiveCounts(db DB) (map[string]int, error) {
|
||||||
|
now := int(time.Now().Unix()) // TODO pass this value in
|
||||||
rows, err := db.Query(`
|
rows, err := db.Query(`
|
||||||
select c.name, count(i.id) as count
|
select c.name, count(i.id) as count
|
||||||
from channels c
|
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
|
group by c.name
|
||||||
`)
|
`, now)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user