-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats.go
42 lines (36 loc) · 1.01 KB
/
stats.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import "fmt"
type stats struct {
UserCount int
ChannelCount int
BoardCount int
ViewCount int
CardCount int
TextCount int
}
func (s *stats) Add(s2 stats) {
s.UserCount += s2.UserCount
s.ChannelCount += s2.ChannelCount
s.BoardCount += s2.BoardCount
s.ViewCount += s2.ViewCount
s.CardCount += s2.CardCount
s.TextCount += s2.TextCount
}
// Print prints the stats to std.out and returns the number of lines output.
func (s *stats) PrintLines() []string {
lines := make([]string, 0, 6)
var line string
line = fmt.Sprintf(" Users: %d", s.UserCount)
lines = append(lines, line)
line = fmt.Sprintf("Channels: %d", s.ChannelCount)
lines = append(lines, line)
line = fmt.Sprintf(" Boards: %d", s.BoardCount)
lines = append(lines, line)
line = fmt.Sprintf(" Views: %d", s.ViewCount)
lines = append(lines, line)
line = fmt.Sprintf(" Cards: %d", s.CardCount)
lines = append(lines, line)
line = fmt.Sprintf(" Text: %d", s.TextCount)
lines = append(lines, line)
return lines
}