feat: add Import entity with batch tracking
This commit is contained in:
41
src/Repository/ImportRepository.php
Normal file
41
src/Repository/ImportRepository.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Import;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Import>
|
||||
*/
|
||||
class ImportRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Import::class);
|
||||
}
|
||||
|
||||
public function incrementProcessedBatches(Import $import): int
|
||||
{
|
||||
$this->getEntityManager()->getConnection()->executeStatement(
|
||||
'UPDATE import SET processed_batches = processed_batches + 1 WHERE id = :id',
|
||||
['id' => $import->getId()]
|
||||
);
|
||||
|
||||
return (int) $this->getEntityManager()->getConnection()->fetchOne(
|
||||
'SELECT processed_batches FROM import WHERE id = :id',
|
||||
['id' => $import->getId()]
|
||||
);
|
||||
}
|
||||
|
||||
public function incrementFailedFilms(Import $import): void
|
||||
{
|
||||
$this->getEntityManager()->getConnection()->executeStatement(
|
||||
'UPDATE import SET failed_films = failed_films + 1 WHERE id = :id',
|
||||
['id' => $import->getId()]
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user