Skip to content

Commit

Permalink
fix: Do not track empty assignment events
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Yiu authored and Tim Yiu committed Sep 19, 2023
1 parent 4a8107c commit a16d809
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/main/kotlin/assignment/AssignmentFilter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ internal class InMemoryAssignmentFilter(size: Int, ttlMillis: Long = DAY_MILLIS)
private val cache = Cache<String, Unit>(size, ttlMillis)

override fun shouldTrack(assignment: Assignment): Boolean {
if (assignment.results.isEmpty()) {
return false
}
val canonicalAssignment = assignment.canonicalize()
val track = cache[canonicalAssignment] == null
if (track) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/kotlin/assignment/AssignmentFilterTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class AssignmentFilterTest {
ExperimentUser(userId = "user"),
mapOf()
)
Assert.assertTrue(filter.shouldTrack(assignment1))
Assert.assertFalse(filter.shouldTrack(assignment1))
val assignment2 = Assignment(
ExperimentUser(userId = "user"),
mapOf()
Expand All @@ -99,7 +99,7 @@ class AssignmentFilterTest {
ExperimentUser(userId = "different user"),
mapOf()
)
Assert.assertTrue(filter.shouldTrack(assignment3))
Assert.assertFalse(filter.shouldTrack(assignment3))
}

@Test
Expand Down

0 comments on commit a16d809

Please sign in to comment.