Permalink
Browse files

Assigned jobs must be a numeric array

Gaps in indices were causing MongoDB $nin operator to fail
  • Loading branch information...
1 parent 302c936 commit 2b9af50985542caddb3395a80ad0131c0f666bec Giorgio Sironi committed Mar 10, 2016
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/Recruiter/Worker.php
@@ -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]);
@@ -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)

0 comments on commit 2b9af50

Please sign in to comment.