Skip to content

Commit

Permalink
fix: Do not track empty assignment events (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyiuhc authored Sep 19, 2023
1 parent 22535e5 commit fcb0102
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pkg/experiment/local/assignment_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ func newAssignmentFilter(size int) *assignmentFilter {
}

func (f *assignmentFilter) shouldTrack(assignment *assignment) bool {
if len(*assignment.results) == 0 {
return false
}
canonicalAssignment := assignment.Canonicalize()
f.mu.Lock()
track, found := f.cache.Get(canonicalAssignment)
Expand Down
8 changes: 4 additions & 4 deletions pkg/experiment/local/assignment_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,14 @@ func TestEmptyResult(t *testing.T) {
assignment2 := newAssignment(user1, results)
assignment3 := newAssignment(user2, results)
filter := newAssignmentFilter(100)
if !filter.shouldTrack(assignment1) {
t.Errorf("Assignment1 should be tracked")
if filter.shouldTrack(assignment1) {
t.Errorf("Assignment1 should not be tracked")
}
if filter.shouldTrack(assignment2) {
t.Errorf("Assignment2 should not be tracked")
}
if !filter.shouldTrack(assignment3) {
t.Errorf("Assignment3 should be tracked")
if filter.shouldTrack(assignment3) {
t.Errorf("Assignment3 should not be tracked")
}
}

Expand Down

0 comments on commit fcb0102

Please sign in to comment.