aboutsummaryrefslogtreecommitdiffstats
path: root/bug
diff options
context:
space:
mode:
authorAmine Hilaly <hilalyamine@gmail.com>2019-03-31 22:32:35 +0200
committerAmine Hilaly <hilalyamine@gmail.com>2019-04-04 00:37:57 +0200
commit2a5fbc4dc988d2eea76fe5e844ccf6425f9386ee (patch)
tree8e5125a64ff3d54fa304ae758ddbbcc427b368af /bug
parent5b0a92dea43f467f31a65a6f02e937d285cb0a71 (diff)
downloadgit-bug-2a5fbc4dc988d2eea76fe5e844ccf6425f9386ee.tar.gz
Expose actors and participants in snapshot and bug excerpt
Append operations authors to each list on Apply() call Expose actors and participants in graphql Add actor/participant query filter and documentation
Diffstat (limited to 'bug')
-rw-r--r--bug/op_add_comment.go3
-rw-r--r--bug/op_create.go3
-rw-r--r--bug/op_create_test.go6
-rw-r--r--bug/op_edit_comment.go2
-rw-r--r--bug/op_label_change.go2
-rw-r--r--bug/op_set_status.go1
-rw-r--r--bug/op_set_title.go1
-rw-r--r--bug/snapshot.go36
8 files changed, 46 insertions, 8 deletions
diff --git a/bug/op_add_comment.go b/bug/op_add_comment.go
index c1e0838b..8cde20e8 100644
--- a/bug/op_add_comment.go
+++ b/bug/op_add_comment.go
@@ -29,6 +29,9 @@ func (op *AddCommentOperation) Hash() (git.Hash, error) {
}
func (op *AddCommentOperation) Apply(snapshot *Snapshot) {
+ snapshot.addActor(op.Author)
+ snapshot.addParticipant(op.Author)
+
hash, err := op.Hash()
if err != nil {
// Should never error unless a programming error happened
diff --git a/bug/op_create.go b/bug/op_create.go
index d5852db9..f3757f89 100644
--- a/bug/op_create.go
+++ b/bug/op_create.go
@@ -30,6 +30,9 @@ func (op *CreateOperation) Hash() (git.Hash, error) {
}
func (op *CreateOperation) Apply(snapshot *Snapshot) {
+ snapshot.addActor(op.Author)
+ snapshot.addParticipant(op.Author)
+
hash, err := op.Hash()
if err != nil {
// Should never error unless a programming error happened
diff --git a/bug/op_create_test.go b/bug/op_create_test.go
index aa1d8c10..2a88f256 100644
--- a/bug/op_create_test.go
+++ b/bug/op_create_test.go
@@ -35,8 +35,10 @@ func TestCreate(t *testing.T) {
Comments: []Comment{
comment,
},
- Author: rene,
- CreatedAt: create.Time(),
+ Author: rene,
+ Participants: []identity.Interface{rene},
+ Actors: []identity.Interface{rene},
+ CreatedAt: create.Time(),
Timeline: []TimelineItem{
&CreateTimelineItem{
CommentTimelineItem: NewCommentTimelineItem(hash, comment),
diff --git a/bug/op_edit_comment.go b/bug/op_edit_comment.go
index 5a223e01..cf5c2d51 100644
--- a/bug/op_edit_comment.go
+++ b/bug/op_edit_comment.go
@@ -33,6 +33,8 @@ func (op *EditCommentOperation) Apply(snapshot *Snapshot) {
// Todo: currently any message can be edited, even by a different author
// crypto signature are needed.
+ snapshot.addActor(op.Author)
+
var target TimelineItem
var commentIndex int
diff --git a/bug/op_label_change.go b/bug/op_label_change.go
index 84542b6e..a2108941 100644
--- a/bug/op_label_change.go
+++ b/bug/op_label_change.go
@@ -31,6 +31,8 @@ func (op *LabelChangeOperation) Hash() (git.Hash, error) {
// Apply apply the operation
func (op *LabelChangeOperation) Apply(snapshot *Snapshot) {
+ snapshot.addActor(op.Author)
+
// Add in the set
AddLoop:
for _, added := range op.Added {
diff --git a/bug/op_set_status.go b/bug/op_set_status.go
index 0105d78d..57d4cf22 100644
--- a/bug/op_set_status.go
+++ b/bug/op_set_status.go
@@ -27,6 +27,7 @@ func (op *SetStatusOperation) Hash() (git.Hash, error) {
func (op *SetStatusOperation) Apply(snapshot *Snapshot) {
snapshot.Status = op.Status
+ snapshot.addActor(op.Author)
hash, err := op.Hash()
if err != nil {
diff --git a/bug/op_set_title.go b/bug/op_set_title.go
index 084838cb..ca27adee 100644
--- a/bug/op_set_title.go
+++ b/bug/op_set_title.go
@@ -31,6 +31,7 @@ func (op *SetTitleOperation) Hash() (git.Hash, error) {
func (op *SetTitleOperation) Apply(snapshot *Snapshot) {
snapshot.Title = op.Title
+ snapshot.addActor(op.Author)
hash, err := op.Hash()
if err != nil {
diff --git a/bug/snapshot.go b/bug/snapshot.go
index 83b94416..53f6873a 100644
--- a/bug/snapshot.go
+++ b/bug/snapshot.go
@@ -12,12 +12,14 @@ import (
type Snapshot struct {
id string
- Status Status
- Title string
- Comments []Comment
- Labels []Label
- Author identity.Interface
- CreatedAt time.Time
+ Status Status
+ Title string
+ Comments []Comment
+ Labels []Label
+ Author identity.Interface
+ Actors []identity.Interface
+ Participants []identity.Interface
+ CreatedAt time.Time
Timeline []TimelineItem
@@ -62,3 +64,25 @@ func (snap *Snapshot) SearchTimelineItem(hash git.Hash) (TimelineItem, error) {
return nil, fmt.Errorf("timeline item not found")
}
+
+// 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.Actors = append(snap.Actors, actor)
+}
+
+// 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() {
+ return
+ }
+ }
+
+ snap.Participants = append(snap.Participants, participant)
+}