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