Cleaner fix to the duplication issue with batch processing.
This commit is contained in:
parent
d28104c686
commit
d00d14d329
|
@ -5,6 +5,7 @@ use App\Entity;
|
|||
use App\MessageQueue;
|
||||
use App\Radio\Filesystem;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use DoctrineBatchUtils\BatchProcessing\SimpleBatchIteratorAggregate;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class FolderPlaylists extends AbstractTask
|
||||
|
@ -39,9 +40,14 @@ class FolderPlaylists extends AbstractTask
|
|||
*/
|
||||
public function run($force = false): void
|
||||
{
|
||||
$stations = $this->em->getRepository(Entity\Station::class)->findAll();
|
||||
$stations = SimpleBatchIteratorAggregate::fromQuery(
|
||||
$this->em->createQuery(/** @lang DQL */ 'SELECT s FROM App\Entity\Station s'),
|
||||
1
|
||||
);
|
||||
|
||||
foreach ($stations as $station) {
|
||||
/** @var Entity\Station $station */
|
||||
|
||||
$this->logger->info('Processing auto-assigning folders for station...', [
|
||||
'station' => $station->getName(),
|
||||
]);
|
||||
|
|
|
@ -76,11 +76,13 @@ class Media extends AbstractTask
|
|||
*/
|
||||
public function run($force = false): void
|
||||
{
|
||||
$stations = $this->em->getRepository(Entity\Station::class)->findAll();
|
||||
$stations = SimpleBatchIteratorAggregate::fromQuery(
|
||||
$this->em->createQuery(/** @lang DQL */ 'SELECT s FROM App\Entity\Station s'),
|
||||
1
|
||||
);
|
||||
|
||||
foreach ($stations as $station) {
|
||||
$station = $this->em->find(Entity\Station::class, $station->getId());
|
||||
|
||||
/** @var Entity\Station $station */
|
||||
$this->logger->info('Processing media for station...', [
|
||||
'station' => $station->getName(),
|
||||
]);
|
||||
|
|
|
@ -38,7 +38,11 @@ class RadioAutomation extends AbstractTask
|
|||
public function run($force = false): void
|
||||
{
|
||||
// Check all stations for automation settings.
|
||||
$stations = $this->em->getRepository(Entity\Station::class)->findAll();
|
||||
// Use this to avoid detached entity errors.
|
||||
$stations = SimpleBatchIteratorAggregate::fromQuery(
|
||||
$this->em->createQuery(/** @lang DQL */ 'SELECT s FROM App\Entity\Station s'),
|
||||
1
|
||||
);
|
||||
|
||||
foreach ($stations as $station) {
|
||||
/** @var Entity\Station $station */
|
||||
|
|
Loading…
Reference in a new issue