1package board
 2
 3import (
 4	"time"
 5
 6	"github.com/MichaelMure/git-bug/entities/identity"
 7	"github.com/MichaelMure/git-bug/entity"
 8)
 9
10type Column struct {
11	Name  string
12	Cards []CardItem
13}
14
15type CardItem interface {
16	// Status() common.Status
17}
18
19type Snapshot struct {
20	id entity.Id
21
22	Title       string
23	Description string
24	Columns     []Column
25	Actors      []identity.Interface
26
27	CreateTime time.Time
28	Operations []Operation
29}
30
31// Id returns the Board identifier
32func (snap *Snapshot) Id() entity.Id {
33	if snap.id == "" {
34		// simply panic as it would be a coding error (no id provided at construction)
35		panic("no id")
36	}
37	return snap.id
38}
39
40// EditTime returns the last time the board was modified
41func (snap *Snapshot) EditTime() time.Time {
42	if len(snap.Operations) == 0 {
43		return time.Unix(0, 0)
44	}
45
46	return snap.Operations[len(snap.Operations)-1].Time()
47}
48
49// append the operation author to the actors list
50func (snap *Snapshot) addActor(actor identity.Interface) {
51	for _, a := range snap.Actors {
52		if actor.Id() == a.Id() {
53			return
54		}
55	}
56
57	snap.Actors = append(snap.Actors, actor)
58}