Statistics API: also show blue v. red cameras

ipad-testing
Noah 2023-06-10 12:54:13 -07:00
parent 6f51a4c739
commit b07baca245
1 changed files with 13 additions and 0 deletions

View File

@ -29,6 +29,10 @@ func (s *Server) Statistics() http.HandlerFunc {
var result = struct {
UserCount int
Usernames []string
Cameras struct {
Blue int
Red int
}
}{
Usernames: []string{},
}
@ -43,6 +47,15 @@ func (s *Server) Statistics() http.HandlerFunc {
}
result.Usernames = append(result.Usernames, sub.Username)
unique[sub.Username] = struct{}{}
// Count cameras by color.
if sub.VideoActive {
if sub.VideoNSFW {
result.Cameras.Red++
} else {
result.Cameras.Blue++
}
}
}
}