Skip to content

Commit

Permalink
Assigned jobs must be a numeric array
Browse files Browse the repository at this point in the history
Gaps in indices were causing MongoDB $nin operator to fail
  • Loading branch information
Giorgio Sironi committed Mar 10, 2016
1 parent 302c936 commit 2b9af50
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Recruiter/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ public static function tryToAssignJobsToWorkers(MongoCollection $collection, $jo
return [$assignment, $result['n']];
}

/**
* @return array of MongoId
*/
public static function assignedJobs(MongoCollection $collection)
{
$cursor = $collection->find([], ['assigned_to' => 1]);
Expand All @@ -220,7 +223,7 @@ public static function assignedJobs(MongoCollection $collection)
$jobs = array_merge($jobs, array_values($document['assigned_to']));
}
}
return array_unique($jobs);
return array_values(array_unique($jobs));
}

public static function retireDeadWorkers(Repository $roster, Clock $clock)
Expand Down

0 comments on commit 2b9af50

Please sign in to comment.