aboutsummaryrefslogtreecommitdiffstats
path: root/bug/snapshot.go
blob: 9b9acf873e16a6ee5041181d5ba9ce361ecb65f6 (plain) (blame)
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
package bug

import (
	"fmt"
	"time"
)

// Snapshot is a compiled form of the Bug data structure used for storage and merge
type Snapshot struct {
	Title    string
	Comments []Comment
	Labels   []Label
}

func (snap Snapshot) Summary() string {
	return fmt.Sprintf("c:%d l:%d %s",
		len(snap.Comments)-1,
		len(snap.Labels),
		snap.LastEdit().Format(time.RFC822),
	)
}

func (snap Snapshot) LastEdit() time.Time {
	lastEditTimestamp := snap.Comments[len(snap.Comments)-1].Time
	return time.Unix(lastEditTimestamp, 0)
}