board: actors instead of participants to match what Bug does

Michael Muré created

Change summary

cache/board_excerpt.go               | 16 ++++++------
commands/cmdjson/board.go            | 26 ++++++++++----------
entities/board/op_add_item_draft.go  |  2 
entities/board/op_add_item_entity.go |  2 
entities/board/op_create.go          |  2 
entities/board/op_set_description.go |  2 
entities/board/op_set_title.go       |  2 
entities/board/snapshot.go           | 37 ++++++++++++++---------------
entities/bug/snapshot.go             | 18 ++++++++-----
9 files changed, 55 insertions(+), 52 deletions(-)

Detailed changes

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(),
 	}
 }

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
 }

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
 		}
 	}

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
 		}
 	}

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

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 {

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 {

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() {}

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