diff --git a/cache/board_excerpt.go b/cache/board_excerpt.go index 6c50b52180bc8155e54e9f6158df15011f647ed0..b13b7e7a274141c6538b79127ef51bbff18b7464 100644 --- a/cache/board_excerpt.go +++ b/cache/board_excerpt.go @@ -25,10 +25,10 @@ type BoardExcerpt struct { CreateUnixTime int64 EditUnixTime int64 - Title string - Description string - ItemCount int - Participants []entity.Id + Title string + Description string + ItemCount int + Actors []entity.Id CreateMetadata map[string]string } @@ -36,9 +36,9 @@ type BoardExcerpt struct { func NewBoardExcerpt(b *BoardCache) *BoardExcerpt { snap := b.Snapshot() - participantsIds := make([]entity.Id, 0, len(snap.Participants)) - for _, participant := range snap.Participants { - participantsIds = append(participantsIds, participant.Id()) + actorsIds := make([]entity.Id, 0, len(snap.Actors)) + for _, participant := range snap.Actors { + actorsIds = append(actorsIds, participant.Id()) } return &BoardExcerpt{ @@ -50,7 +50,7 @@ func NewBoardExcerpt(b *BoardCache) *BoardExcerpt { Title: snap.Title, Description: snap.Description, ItemCount: snap.ItemCount(), - Participants: participantsIds, + Actors: actorsIds, CreateMetadata: b.FirstOp().AllMetadata(), } } diff --git a/commands/cmdjson/board.go b/commands/cmdjson/board.go index 0ca9196fb8b1243b8a231d8d66ff0a3fecadcd69..ba9d4970fc99e4daa13616cdda384aa2de77c688 100644 --- a/commands/cmdjson/board.go +++ b/commands/cmdjson/board.go @@ -11,10 +11,10 @@ type BoardSnapshot struct { CreateTime Time `json:"create_time"` EditTime Time `json:"edit_time"` - Title string `json:"title"` - Description string `json:"description"` - Participants []Identity `json:"participants"` - Columns []BoardColumn `json:"columns"` + Title string `json:"title"` + Description string `json:"description"` + Actors []Identity `json:"participants"` + Columns []BoardColumn `json:"columns"` } func NewBoardSnapshot(snapshot *board.Snapshot) BoardSnapshot { @@ -27,9 +27,9 @@ func NewBoardSnapshot(snapshot *board.Snapshot) BoardSnapshot { Description: snapshot.Description, } - jsonBoard.Participants = make([]Identity, len(snapshot.Participants)) - for i, element := range snapshot.Participants { - jsonBoard.Participants[i] = NewIdentity(element) + jsonBoard.Actors = make([]Identity, len(snapshot.Actors)) + for i, element := range snapshot.Actors { + jsonBoard.Actors[i] = NewIdentity(element) } jsonBoard.Columns = make([]BoardColumn, len(snapshot.Columns)) @@ -112,9 +112,9 @@ type BoardExcerpt struct { CreateTime Time `json:"create_time"` EditTime Time `json:"edit_time"` - Title string `json:"title"` - Description string `json:"description"` - Participants []Identity `json:"participants"` + Title string `json:"title"` + Description string `json:"description"` + Actors []Identity `json:"participants"` Items int `json:"items"` Metadata map[string]string `json:"metadata"` @@ -132,13 +132,13 @@ func NewBoardExcerpt(backend *cache.RepoCache, b *cache.BoardExcerpt) (BoardExce Metadata: b.CreateMetadata, } - jsonBoard.Participants = make([]Identity, len(b.Participants)) - for i, element := range b.Participants { + jsonBoard.Actors = make([]Identity, len(b.Actors)) + for i, element := range b.Actors { participant, err := backend.Identities().ResolveExcerpt(element) if err != nil { return BoardExcerpt{}, err } - jsonBoard.Participants[i] = NewIdentityFromExcerpt(participant) + jsonBoard.Actors[i] = NewIdentityFromExcerpt(participant) } return jsonBoard, nil } diff --git a/entities/board/op_add_item_draft.go b/entities/board/op_add_item_draft.go index 47528cf525b0de6d4dcecb25684bb44cb481fc8b..f5ccfa55c42edfd8a5657512b0ded6bd068c7a8f 100644 --- a/entities/board/op_add_item_draft.go +++ b/entities/board/op_add_item_draft.go @@ -73,7 +73,7 @@ func (op *AddItemDraftOperation) Apply(snapshot *Snapshot) { unixTime: timestamp.Timestamp(op.UnixTime), }) - snapshot.addParticipant(op.Author()) + snapshot.addActor(op.Author()) return } } diff --git a/entities/board/op_add_item_entity.go b/entities/board/op_add_item_entity.go index 7502eaffa347bc78e6653941c9df3effda3ef643..94781875da30720e5fff7e8ce979c8793613c8ed 100644 --- a/entities/board/op_add_item_entity.go +++ b/entities/board/op_add_item_entity.go @@ -71,7 +71,7 @@ func (op *AddItemEntityOperation) Apply(snapshot *Snapshot) { Bug: op.entity.(dag.CompileTo[*bug.Snapshot]), }) } - snapshot.addParticipant(op.Author()) + snapshot.addActor(op.Author()) return } } diff --git a/entities/board/op_create.go b/entities/board/op_create.go index 673bd742350e83e8d15462a78e106ba11af18e30..bad648d7dd979b14127b375b2d2f9fcfa5ad0025 100644 --- a/entities/board/op_create.go +++ b/entities/board/op_create.go @@ -103,7 +103,7 @@ func (op *CreateOperation) Apply(snap *Snapshot) { }) } - snap.addParticipant(op.Author()) + snap.addActor(op.Author()) } // CreateDefaultColumns is a convenience function to create a board with the default columns diff --git a/entities/board/op_set_description.go b/entities/board/op_set_description.go index 94bf7fda7c86032d1233cbf99939a8db307cbfeb..4de731d78e235dff4a7a9878fa5539707749a038 100644 --- a/entities/board/op_set_description.go +++ b/entities/board/op_set_description.go @@ -44,7 +44,7 @@ func (op *SetDescriptionOperation) Validate() error { func (op *SetDescriptionOperation) Apply(snapshot *Snapshot) { snapshot.Description = op.Description - snapshot.addParticipant(op.Author()) + snapshot.addActor(op.Author()) } func NewSetDescriptionOp(author identity.Interface, unixTime int64, description string, was string) *SetDescriptionOperation { diff --git a/entities/board/op_set_title.go b/entities/board/op_set_title.go index 35c7ef8e0f4a4dafbbf4e6ca9f805206e4749c75..63f8962a613260acfdad2f3338e727f378f52020 100644 --- a/entities/board/op_set_title.go +++ b/entities/board/op_set_title.go @@ -44,7 +44,7 @@ func (op *SetTitleOperation) Validate() error { func (op *SetTitleOperation) Apply(snapshot *Snapshot) { snapshot.Title = op.Title - snapshot.addParticipant(op.Author()) + snapshot.addActor(op.Author()) } func NewSetTitleOp(author identity.Interface, unixTime int64, title string, was string) *SetTitleOperation { diff --git a/entities/board/snapshot.go b/entities/board/snapshot.go index 0065aed71ccd837ea28d4e067f09ca14cd8b5532..b2c22dc87439dd3d9e15421fab8149b2b63a64fa 100644 --- a/entities/board/snapshot.go +++ b/entities/board/snapshot.go @@ -41,12 +41,14 @@ var _ dag.Snapshot = &Snapshot{} type Snapshot struct { id entity.Id - Title string - Description string - Columns []*Column - Participants []identity.Interface + CreateTime time.Time + Title string + Description string + Columns []*Column + + // Actors are all the identities that have interacted with the board (add items ...) + Actors []identity.Interface - CreateTime time.Time Operations []dag.Operation } @@ -87,20 +89,20 @@ func (snap *Snapshot) SearchColumn(id entity.CombinedId) (*Column, error) { return nil, fmt.Errorf("column not found") } -// append the operation author to the participants list -func (snap *Snapshot) addParticipant(participant identity.Interface) { - for _, p := range snap.Participants { - if participant.Id() == p.Id() { +// append the operation author to the actors list +func (snap *Snapshot) addActor(actor identity.Interface) { + for _, a := range snap.Actors { + if actor.Id() == a.Id() { return } } - snap.Participants = append(snap.Participants, participant) + snap.Actors = append(snap.Actors, actor) } -// HasParticipant return true if the id is a participant -func (snap *Snapshot) HasParticipant(id entity.Id) bool { - for _, p := range snap.Participants { +// HasActor return true if the id is a actor +func (snap *Snapshot) HasActor(id entity.Id) bool { + for _, p := range snap.Actors { if p.Id() == id { return true } @@ -108,10 +110,10 @@ func (snap *Snapshot) HasParticipant(id entity.Id) bool { return false } -// HasAnyParticipant return true if one of the ids is a participant -func (snap *Snapshot) HasAnyParticipant(ids ...entity.Id) bool { +// HasAnyActor return true if one of the ids is a actor +func (snap *Snapshot) HasAnyActor(ids ...entity.Id) bool { for _, id := range ids { - if snap.HasParticipant(id) { + if snap.HasActor(id) { return true } } @@ -126,6 +128,3 @@ func (snap *Snapshot) ItemCount() int { } return count } - -// IsAuthored is a sign post method for gqlgen -func (snap *Snapshot) IsAuthored() {} diff --git a/entities/bug/snapshot.go b/entities/bug/snapshot.go index 7f9e7e580298a30baccc97a6e722b18bd56046b8..cda6fb5b2240c52780c6ced8598d1af366b18db7 100644 --- a/entities/bug/snapshot.go +++ b/entities/bug/snapshot.go @@ -16,14 +16,18 @@ var _ dag.Snapshot = &Snapshot{} type Snapshot struct { id entity.Id - Status common.Status - Title string - Comments []Comment - Labels []common.Label - Author identity.Interface - Actors []identity.Interface + CreateTime time.Time + Status common.Status + Title string + Comments []Comment + Labels []common.Label + + // Author is the creator of the bug + Author identity.Interface + // Actors are all the identities that have interacted with the bug (comments, status ...) + Actors []identity.Interface + // Participants are all the identities that have created or added a comment on the bug Participants []identity.Interface - CreateTime time.Time Timeline []TimelineItem