mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
add time to message, ad status info in worker table, fix subdef elastic flush
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Alchemy\Phrasea\Model\Repositories;
|
||||
|
||||
use Alchemy\Phrasea\Core\PhraseaTokens;
|
||||
use Alchemy\Phrasea\Model\Entities\WorkerRunningJob;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
class WorkerRunningJobRepository extends EntityRepository
|
||||
@@ -23,7 +24,8 @@ class WorkerRunningJobRepository extends EntityRepository
|
||||
FROM WorkerRunningJob
|
||||
WHERE ((work & :write_meta) > 0 OR ((work & :make_subdef) > 0 AND work_on = :work_on) )
|
||||
AND record_id = :record_id
|
||||
AND databox_id = :databox_id';
|
||||
AND databox_id = :databox_id
|
||||
AND status = :status';
|
||||
|
||||
$query = $this->_em->createNativeQuery($sql, $rsm);
|
||||
$query->setParameters([
|
||||
@@ -31,7 +33,8 @@ class WorkerRunningJobRepository extends EntityRepository
|
||||
'make_subdef'=> PhraseaTokens::MAKE_SUBDEF,
|
||||
'work_on' => $subdefName,
|
||||
'record_id' => $recordId,
|
||||
'databox_id' => $databoxId
|
||||
'databox_id' => $databoxId,
|
||||
'status' => WorkerRunningJob::RUNNING
|
||||
]
|
||||
);
|
||||
|
||||
@@ -55,7 +58,8 @@ class WorkerRunningJobRepository extends EntityRepository
|
||||
FROM WorkerRunningJob
|
||||
WHERE ((work & :make_subdef) > 0 OR ((work & :write_meta) > 0 AND work_on = :work_on) )
|
||||
AND record_id = :record_id
|
||||
AND databox_id = :databox_id';
|
||||
AND databox_id = :databox_id
|
||||
AND status = :status';
|
||||
|
||||
$query = $this->_em->createNativeQuery($sql, $rsm);
|
||||
$query->setParameters([
|
||||
@@ -63,10 +67,34 @@ class WorkerRunningJobRepository extends EntityRepository
|
||||
'write_meta' => PhraseaTokens::WRITE_META,
|
||||
'work_on' => $subdefName,
|
||||
'record_id' => $recordId,
|
||||
'databox_id' => $databoxId
|
||||
'databox_id' => $databoxId,
|
||||
'status' => WorkerRunningJob::RUNNING
|
||||
]
|
||||
);
|
||||
|
||||
return count($query->getResult()) == 0;
|
||||
}
|
||||
|
||||
public function truncateWorkerTable()
|
||||
{
|
||||
$connection = $this->_em->getConnection();
|
||||
$platform = $connection->getDatabasePlatform();
|
||||
$this->_em->beginTransaction();
|
||||
try {
|
||||
$connection->executeUpdate($platform->getTruncateTableSQL('WorkerRunningJob'));
|
||||
} catch (\Exception $e) {
|
||||
$this->_em->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteFinishedWorks()
|
||||
{
|
||||
$this->_em->beginTransaction();
|
||||
try {
|
||||
$this->_em->getConnection()->delete('WorkerRunningJob', ['status' => WorkerRunningJob::FINISHED]);
|
||||
$this->_em->commit();
|
||||
} catch (\Exception $e) {
|
||||
$this->_em->rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user