1package bug
2
3import (
4 "fmt"
5 "time"
6)
7
8// Snapshot is a compiled form of the Bug data structure used for storage and merge
9type Snapshot struct {
10 id string
11
12 Status Status
13 Title string
14 Comments []Comment
15 Labels []Label
16 Author Person
17 CreatedAt time.Time
18
19 Operations []Operation
20}
21
22// Return the Bug identifier
23func (snap Snapshot) Id() string {
24 return snap.id
25}
26
27// Return the Bug identifier truncated for human consumption
28func (snap Snapshot) HumanId() string {
29 return fmt.Sprintf("%.8s", snap.id)
30}
31
32func (snap Snapshot) Summary() string {
33 return fmt.Sprintf("C:%d L:%d",
34 len(snap.Comments)-1,
35 len(snap.Labels),
36 )
37}
38
39// Return the last time a bug was modified
40func (snap Snapshot) LastEdit() time.Time {
41 if len(snap.Operations) == 0 {
42 return time.Unix(0, 0)
43 }
44
45 return snap.Operations[len(snap.Operations)-1].Time()
46}