snapshot.go

 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	Title    string
11	Comments []Comment
12	Labels   []Label
13}
14
15func (snap Snapshot) Summary() string {
16	return fmt.Sprintf("c:%d l:%d %s",
17		len(snap.Comments)-1,
18		len(snap.Labels),
19		snap.LastEdit().Format(time.RFC822),
20	)
21}
22
23func (snap Snapshot) LastEdit() time.Time {
24	lastEditTimestamp := snap.Comments[len(snap.Comments)-1].Time
25	return time.Unix(lastEditTimestamp, 0)
26}