Calculating the total of users in a channel
This commit is contained in:
@@ -73,9 +73,14 @@ func (c *Channel) TotalSubscriptions() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the total of users.
|
// Get the total of users.
|
||||||
// For now, totalUsers is equal to totalSubscribers
|
|
||||||
func (c *Channel) TotalUsers() int {
|
func (c *Channel) TotalUsers() int {
|
||||||
return c.TotalSubscriptions()
|
total := make(map[string]int)
|
||||||
|
|
||||||
|
for _, s := range c.Subscriptions {
|
||||||
|
total[s.Id]++
|
||||||
|
}
|
||||||
|
|
||||||
|
return len(total)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a new subscriber to the channel
|
// Add a new subscriber to the channel
|
||||||
|
|||||||
Reference in New Issue
Block a user