-
Notifications
You must be signed in to change notification settings - Fork 24
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Package version
v5.0.5
Describe the bug
In ->chunk() and ->chunkById(), if posts count is anything but 1000, it stops the loop after 1000 models (or just one chunk)
For example:
Post::chunkById(100, callback) only gets 1000 posts, but
Post::chunkById(1000, callback) gets all the posts there are (4750 items)
To Reproduce
Steps to reproduce the behavior:
$counter = 0;
$set = [];
Post::chunkById(100, function ($models) use (&$counter, &$set) {
$counter += count($models);
foreach ($models as $model) {
$set[] = $model->_id;
}
echo "Counter reached: " . $counter . "\n";
if ($counter > 10000) {
return false; // Stop the chunking
}
});
$this->info("Total count: " . $counter);
$this->info("Set size: " . count($set));
$this->info("Unique IDs: " . count(array_unique($set)));
Expected behavior
Each chunk should have expected number of posts and should run until there are no more posts
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working