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