Skip to content

Commit

Permalink
fix: don't track empty assignment events (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgiori authored Sep 19, 2023
1 parent e0a4e52 commit 53f3506
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/node/src/assignment/assignment-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export class InMemoryAssignmentFilter implements AssignmentFilter {
}

public shouldTrack(assignment: Assignment): boolean {
if (Object.keys(assignment.results).length === 0) {
// Don't track empty assignments.
return false;
}
const canonicalAssignment = assignment.canonicalize();
const track = this.cache.get(canonicalAssignment) == undefined;
if (track) {
Expand Down
4 changes: 2 additions & 2 deletions packages/node/test/local/assignment/assignment-filter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ test('filter - empty result', async () => {
const assignment1 = new Assignment(user1, {});
const assignment2 = new Assignment(user1, {});
const assignment3 = new Assignment(user2, {});
expect(filter.shouldTrack(assignment1)).toEqual(true);
expect(filter.shouldTrack(assignment1)).toEqual(false);
expect(filter.shouldTrack(assignment2)).toEqual(false);
expect(filter.shouldTrack(assignment3)).toEqual(true);
expect(filter.shouldTrack(assignment3)).toEqual(false);
});

test('filter - duplicate assignments with different result ordering', async () => {
Expand Down

0 comments on commit 53f3506

Please sign in to comment.