Statistics API: also show blue v. red cameras
This commit is contained in:
parent
6f51a4c739
commit
b07baca245
13
pkg/api.go
13
pkg/api.go
|
@ -29,6 +29,10 @@ func (s *Server) Statistics() http.HandlerFunc {
|
||||||
var result = struct {
|
var result = struct {
|
||||||
UserCount int
|
UserCount int
|
||||||
Usernames []string
|
Usernames []string
|
||||||
|
Cameras struct {
|
||||||
|
Blue int
|
||||||
|
Red int
|
||||||
|
}
|
||||||
}{
|
}{
|
||||||
Usernames: []string{},
|
Usernames: []string{},
|
||||||
}
|
}
|
||||||
|
@ -43,6 +47,15 @@ func (s *Server) Statistics() http.HandlerFunc {
|
||||||
}
|
}
|
||||||
result.Usernames = append(result.Usernames, sub.Username)
|
result.Usernames = append(result.Usernames, sub.Username)
|
||||||
unique[sub.Username] = struct{}{}
|
unique[sub.Username] = struct{}{}
|
||||||
|
|
||||||
|
// Count cameras by color.
|
||||||
|
if sub.VideoActive {
|
||||||
|
if sub.VideoNSFW {
|
||||||
|
result.Cameras.Red++
|
||||||
|
} else {
|
||||||
|
result.Cameras.Blue++
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user