PHRAS-3719 filter on job type (#4118)

* filter on job type

* fix
This commit is contained in:
Aina Sitraka
2022-09-07 17:57:49 +03:00
committed by GitHub
parent 54a96ee8df
commit 70b2658302
13 changed files with 1714 additions and 1634 deletions

View File

@@ -379,11 +379,20 @@ class WorkerRunningJobRepository extends EntityRepository
return count($qb->getQuery()->getResult()); return count($qb->getQuery()->getResult());
} }
public function findByStatus(array $status, $start = 0, $limit = WorkerRunningJob::MAX_RESULT) public function findByStatusAndJob(array $status, $jobType, $start = 0, $limit = WorkerRunningJob::MAX_RESULT)
{ {
$qb = $this->createQueryBuilder('w'); $qb = $this->createQueryBuilder('w');
if (!empty($status)) {
$qb->where($qb->expr()->in('w.status', $status));
}
if (!empty($jobType)) {
$qb->andWhere('w.work = :work')
->setParameter('work', $jobType);
}
$qb $qb
->where($qb->expr()->in('w.status', $status))
->setFirstResult($start) ->setFirstResult($start)
->setMaxResults($limit) ->setMaxResults($limit)
->orderBy('w.id', 'DESC') ->orderBy('w.id', 'DESC')

View File

@@ -4,7 +4,6 @@ namespace Alchemy\Phrasea\WorkerManager\Controller;
use Alchemy\Phrasea\Application as PhraseaApplication; use Alchemy\Phrasea\Application as PhraseaApplication;
use Alchemy\Phrasea\Controller\Controller; use Alchemy\Phrasea\Controller\Controller;
use Alchemy\Phrasea\Core\Configuration\PropertyAccess;
use Alchemy\Phrasea\Model\Entities\WorkerRunningJob; use Alchemy\Phrasea\Model\Entities\WorkerRunningJob;
use Alchemy\Phrasea\Model\Repositories\WorkerRunningJobRepository; use Alchemy\Phrasea\Model\Repositories\WorkerRunningJobRepository;
use Alchemy\Phrasea\SearchEngine\Elastic\ElasticsearchOptions; use Alchemy\Phrasea\SearchEngine\Elastic\ElasticsearchOptions;
@@ -32,22 +31,8 @@ class AdminConfigurationController extends Controller
{ {
public function indexAction(PhraseaApplication $app, Request $request) public function indexAction(PhraseaApplication $app, Request $request)
{ {
/** @var WorkerRunningJobRepository $repoWorker */
$repoWorker = $app['repo.worker-running-job'];
$filterStatus = [
WorkerRunningJob::RUNNING,
WorkerRunningJob::FINISHED,
WorkerRunningJob::ERROR,
WorkerRunningJob::INTERRUPT
];
$workerRunningJob = $repoWorker->findByStatus($filterStatus);
return $this->render('admin/worker-manager/index.html.twig', [ return $this->render('admin/worker-manager/index.html.twig', [
'isConnected' => $this->getAMQPConnection()->getChannel() != null, 'isConnected' => $this->getAMQPConnection()->getChannel() != null,
'workerRunningJob' => $workerRunningJob,
'reload' => false,
'_fragment' => $request->get('_fragment') ?? 'worker-configuration', '_fragment' => $request->get('_fragment') ?? 'worker-configuration',
]); ]);
} }
@@ -120,9 +105,10 @@ class AdminConfigurationController extends Controller
$repoWorker = $app['repo.worker-running-job']; $repoWorker = $app['repo.worker-running-job'];
$reload = ($request->query->get('reload') == 1); $reload = ($request->query->get('reload') == 1);
$jobType = $request->query->get('jobType');
$workerRunningJob = [];
$filterStatus = []; $filterStatus = [];
if ($request->query->get('running') == 1) { if ($request->query->get('running') == 1) {
$filterStatus[] = WorkerRunningJob::RUNNING; $filterStatus[] = WorkerRunningJob::RUNNING;
} }
@@ -136,13 +122,19 @@ class AdminConfigurationController extends Controller
$filterStatus[] = WorkerRunningJob::INTERRUPT; $filterStatus[] = WorkerRunningJob::INTERRUPT;
} }
if (count($filterStatus) > 0) { $workerRunningJob = $repoWorker->findByStatusAndJob($filterStatus, $jobType);
$workerRunningJob = $repoWorker->findByStatus($filterStatus);
} $types = AMQPConnection::MESSAGES;
// these types are not included in workerRunningJob
unset($types['mainQueue'], $types['createRecord'], $types['pullAssets'], $types['validationReminder']);
$jobTypes = array_keys($types);
return $this->render('admin/worker-manager/worker_info.html.twig', [ return $this->render('admin/worker-manager/worker_info.html.twig', [
'workerRunningJob' => $workerRunningJob, 'workerRunningJob' => $workerRunningJob,
'reload' => $reload 'reload' => $reload,
'jobTypes' => $jobTypes
]); ]);
} }

View File

@@ -11,10 +11,12 @@ use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Model\Entities\Basket; use Alchemy\Phrasea\Model\Entities\Basket;
use Alchemy\Phrasea\Model\Entities\BasketParticipant; use Alchemy\Phrasea\Model\Entities\BasketParticipant;
use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Entities\WorkerRunningJob;
use Alchemy\Phrasea\Model\Manipulator\TokenManipulator; use Alchemy\Phrasea\Model\Manipulator\TokenManipulator;
use Alchemy\Phrasea\Model\Repositories\BasketRepository; use Alchemy\Phrasea\Model\Repositories\BasketRepository;
use Alchemy\Phrasea\Model\Repositories\UserRepository; use Alchemy\Phrasea\Model\Repositories\UserRepository;
use Alchemy\Phrasea\Record\RecordReference; use Alchemy\Phrasea\Record\RecordReference;
use Alchemy\Phrasea\WorkerManager\Queue\MessagePublisher;
use DateTime; use DateTime;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Exception; use Exception;
@@ -32,6 +34,33 @@ class ShareBasketWorker implements WorkerInterface
public function process(array $payload) public function process(array $payload)
{ {
$manager = $this->getEntityManager();
$manager->beginTransaction();
$date = new \DateTime();
$message = [
'message_type' => MessagePublisher::SHARE_BASKET_TYPE,
'payload' => $payload
];
try {
$workerRunningJob = new WorkerRunningJob();
$workerRunningJob
->setWork(MessagePublisher::SHARE_BASKET_TYPE)
->setPayload($message)
->setPublished($date->setTimestamp($payload['published']))
->setStatus(WorkerRunningJob::RUNNING)
;
$manager->persist($workerRunningJob);
$manager->flush();
$manager->commit();
} catch (\Exception $e) {
$manager->rollback();
}
$isFeedback = $payload['isFeedback']; $isFeedback = $payload['isFeedback'];
$participants = $payload['participants']; $participants = $payload['participants'];
$feedbackAction = $payload['feedbackAction']; $feedbackAction = $payload['feedbackAction'];
@@ -369,6 +398,17 @@ class ShareBasketWorker implements WorkerInterface
$this->getLogger()->info("Basket with Id " . $basket->getId() . " successfully shared !"); $this->getLogger()->info("Basket with Id " . $basket->getId() . " successfully shared !");
if ($workerRunningJob != null) {
$workerRunningJob
->setStatus(WorkerRunningJob::FINISHED)
->setFinished(new \DateTime('now'))
;
$manager->persist($workerRunningJob);
$manager->flush();
}
// file_put_contents("./tmp/phraseanet-log.txt", sprintf("\n%s; ==== END (N = %d ; dT = %d ==> %0.2f / sec) ====\n\n", time(), $n_participants, time()-$_t0, $n_participants/(max(time()-$_t0, 0.001))), FILE_APPEND); // file_put_contents("./tmp/phraseanet-log.txt", sprintf("\n%s; ==== END (N = %d ; dT = %d ==> %0.2f / sec) ====\n\n", time(), $n_participants, time()-$_t0, $n_participants/(max(time()-$_t0, 0.001))), FILE_APPEND);
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2"> <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2022-09-02T14:06:42Z" source-language="en" target-language="de" datatype="plaintext" original="not.available"> <file date="2022-09-07T13:54:18Z" source-language="en" target-language="de" datatype="plaintext" original="not.available">
<header> <header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/> <tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note> <note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
@@ -9,8 +9,8 @@
<trans-unit id="96f0767cb7ea65a7f86c8c9432e80d16cf9d8680" resname="Please provide the same passwords." approved="yes"> <trans-unit id="96f0767cb7ea65a7f86c8c9432e80d16cf9d8680" resname="Please provide the same passwords." approved="yes">
<source>Please provide the same passwords.</source> <source>Please provide the same passwords.</source>
<target state="translated">Bitte geben Sie diesselbe Passwörter ein.</target> <target state="translated">Bitte geben Sie diesselbe Passwörter ein.</target>
<jms:reference-file line="38">Form/Login/PhraseaRenewPasswordForm.php</jms:reference-file>
<jms:reference-file line="46">Form/Login/PhraseaRecoverPasswordForm.php</jms:reference-file> <jms:reference-file line="46">Form/Login/PhraseaRecoverPasswordForm.php</jms:reference-file>
<jms:reference-file line="38">Form/Login/PhraseaRenewPasswordForm.php</jms:reference-file>
<jms:reference-file line="58">Form/Login/PhraseaRegisterForm.php</jms:reference-file> <jms:reference-file line="58">Form/Login/PhraseaRegisterForm.php</jms:reference-file>
</trans-unit> </trans-unit>
<trans-unit id="90b8c9717bb7ed061dbf20fe1986c8b8593d43d4" resname="The token provided is not valid anymore" approved="yes"> <trans-unit id="90b8c9717bb7ed061dbf20fe1986c8b8593d43d4" resname="The token provided is not valid anymore" approved="yes">

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2"> <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2022-09-02T14:08:43Z" source-language="en" target-language="en" datatype="plaintext" original="not.available"> <file date="2022-09-07T13:54:36Z" source-language="en" target-language="en" datatype="plaintext" original="not.available">
<header> <header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/> <tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note> <note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
@@ -9,8 +9,8 @@
<trans-unit id="96f0767cb7ea65a7f86c8c9432e80d16cf9d8680" resname="Please provide the same passwords." approved="yes"> <trans-unit id="96f0767cb7ea65a7f86c8c9432e80d16cf9d8680" resname="Please provide the same passwords." approved="yes">
<source>Please provide the same passwords.</source> <source>Please provide the same passwords.</source>
<target state="translated">Please provide the same passwords.</target> <target state="translated">Please provide the same passwords.</target>
<jms:reference-file line="38">Form/Login/PhraseaRenewPasswordForm.php</jms:reference-file>
<jms:reference-file line="46">Form/Login/PhraseaRecoverPasswordForm.php</jms:reference-file> <jms:reference-file line="46">Form/Login/PhraseaRecoverPasswordForm.php</jms:reference-file>
<jms:reference-file line="38">Form/Login/PhraseaRenewPasswordForm.php</jms:reference-file>
<jms:reference-file line="58">Form/Login/PhraseaRegisterForm.php</jms:reference-file> <jms:reference-file line="58">Form/Login/PhraseaRegisterForm.php</jms:reference-file>
</trans-unit> </trans-unit>
<trans-unit id="90b8c9717bb7ed061dbf20fe1986c8b8593d43d4" resname="The token provided is not valid anymore" approved="yes"> <trans-unit id="90b8c9717bb7ed061dbf20fe1986c8b8593d43d4" resname="The token provided is not valid anymore" approved="yes">

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2"> <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2022-09-02T14:11:03Z" source-language="en" target-language="fr" datatype="plaintext" original="not.available"> <file date="2022-09-07T13:54:54Z" source-language="en" target-language="fr" datatype="plaintext" original="not.available">
<header> <header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/> <tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note> <note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
@@ -9,8 +9,8 @@
<trans-unit id="96f0767cb7ea65a7f86c8c9432e80d16cf9d8680" resname="Please provide the same passwords." approved="yes"> <trans-unit id="96f0767cb7ea65a7f86c8c9432e80d16cf9d8680" resname="Please provide the same passwords." approved="yes">
<source>Please provide the same passwords.</source> <source>Please provide the same passwords.</source>
<target state="translated">Veuillez indiquer des mots de passe identiques.</target> <target state="translated">Veuillez indiquer des mots de passe identiques.</target>
<jms:reference-file line="38">Form/Login/PhraseaRenewPasswordForm.php</jms:reference-file>
<jms:reference-file line="46">Form/Login/PhraseaRecoverPasswordForm.php</jms:reference-file> <jms:reference-file line="46">Form/Login/PhraseaRecoverPasswordForm.php</jms:reference-file>
<jms:reference-file line="38">Form/Login/PhraseaRenewPasswordForm.php</jms:reference-file>
<jms:reference-file line="58">Form/Login/PhraseaRegisterForm.php</jms:reference-file> <jms:reference-file line="58">Form/Login/PhraseaRegisterForm.php</jms:reference-file>
</trans-unit> </trans-unit>
<trans-unit id="90b8c9717bb7ed061dbf20fe1986c8b8593d43d4" resname="The token provided is not valid anymore" approved="yes"> <trans-unit id="90b8c9717bb7ed061dbf20fe1986c8b8593d43d4" resname="The token provided is not valid anymore" approved="yes">

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2"> <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2022-09-02T14:13:35Z" source-language="en" target-language="nl" datatype="plaintext" original="not.available"> <file date="2022-09-07T13:55:15Z" source-language="en" target-language="nl" datatype="plaintext" original="not.available">
<header> <header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/> <tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note> <note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
@@ -9,8 +9,8 @@
<trans-unit id="96f0767cb7ea65a7f86c8c9432e80d16cf9d8680" resname="Please provide the same passwords."> <trans-unit id="96f0767cb7ea65a7f86c8c9432e80d16cf9d8680" resname="Please provide the same passwords.">
<source>Please provide the same passwords.</source> <source>Please provide the same passwords.</source>
<target state="new">Please provide the same passwords.</target> <target state="new">Please provide the same passwords.</target>
<jms:reference-file line="38">Form/Login/PhraseaRenewPasswordForm.php</jms:reference-file>
<jms:reference-file line="46">Form/Login/PhraseaRecoverPasswordForm.php</jms:reference-file> <jms:reference-file line="46">Form/Login/PhraseaRecoverPasswordForm.php</jms:reference-file>
<jms:reference-file line="38">Form/Login/PhraseaRenewPasswordForm.php</jms:reference-file>
<jms:reference-file line="58">Form/Login/PhraseaRegisterForm.php</jms:reference-file> <jms:reference-file line="58">Form/Login/PhraseaRegisterForm.php</jms:reference-file>
</trans-unit> </trans-unit>
<trans-unit id="90b8c9717bb7ed061dbf20fe1986c8b8593d43d4" resname="The token provided is not valid anymore"> <trans-unit id="90b8c9717bb7ed061dbf20fe1986c8b8593d43d4" resname="The token provided is not valid anymore">

View File

@@ -11,7 +11,7 @@
</a> </a>
</li> </li>
<li class="worker-info" role="presentation"> <li class="worker-info" role="presentation">
<a href="#worker-info" aria-controls="worker-info" role="tab" data-toggle="tab" data-url="/admin/worker-manager/info"> <a href="#worker-info" aria-controls="worker-info" role="tab" data-toggle="tab" data-url="/admin/worker-manager/info?running=1">
{{ 'admin::workermanager:tab:workerinfo: title' |trans }} {{ 'admin::workermanager:tab:workerinfo: title' |trans }}
</a> </a>
</li> </li>

View File

@@ -31,18 +31,27 @@
{{ 'admin::workermanager:tab:workerinfo: Refresh list' |trans }} {{ 'admin::workermanager:tab:workerinfo: Refresh list' |trans }}
</button> </button>
<div style="margin-top: 10px;margin-bottom: 10px;">
<select id="job-type-filter">
<option value="">{{ 'boutton::choose job type' | trans }}</option>
{% for jobType in jobTypes %}
<option value="{{ jobType }}">{{ jobType }}</option>
{% endfor %}
</select>
</div>
<div class="controls"> <div class="controls">
<label class="checkbox inline"> <label class="checkbox inline">
<input class="running-work refresh-list-checkbox" type="checkbox" value="1" checked> {{ 'admin::workermanager:tab:workerinfo: Display running work' | trans }} <input class="running-work refresh-list-checkbox" type="checkbox" value="1" checked> {{ 'admin::workermanager:tab:workerinfo: Display running work' | trans }}
</label> </label>
<label class="checkbox inline"> <label class="checkbox inline">
<input class="finished-work refresh-list-checkbox" type="checkbox" value="1" checked> {{ 'admin::workermanager:tab:workerinfo: Display finished work' | trans }} <input class="finished-work refresh-list-checkbox" type="checkbox" value="1" > {{ 'admin::workermanager:tab:workerinfo: Display finished work' | trans }}
</label> </label>
<label class="checkbox inline"> <label class="checkbox inline">
<input class="error-work refresh-list-checkbox" type="checkbox" value="1" checked> {{ 'admin::workermanager:tab:workerinfo: Display error work' | trans }} <input class="error-work refresh-list-checkbox" type="checkbox" value="1" > {{ 'admin::workermanager:tab:workerinfo: Display error work' | trans }}
</label> </label>
<label class="checkbox inline"> <label class="checkbox inline">
<input class="interrupt-work refresh-list-checkbox" type="checkbox" value="1" checked> {{ 'admin::workermanager:tab:workerinfo: Display manually interrupt work' | trans }} <input class="interrupt-work refresh-list-checkbox" type="checkbox" value="1" > {{ 'admin::workermanager:tab:workerinfo: Display manually interrupt work' | trans }}
</label> </label>
</div> </div>
@@ -115,6 +124,7 @@
var finished = 1; var finished = 1;
var error = 1; var error = 1;
var interrupt = 1; var interrupt = 1;
var jobType = $("#job-type-filter").val();
if (!$(".running-work").is(":checked")) if (!$(".running-work").is(":checked"))
{ {
@@ -136,18 +146,27 @@
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: "/admin/worker-manager/info?reload=1&running="+running+"&finished="+finished+"&error="+error+"&interrupt="+interrupt, url: "/admin/worker-manager/info?reload=1&running="+running+"&finished="+finished+"&error="+error+"&interrupt="+interrupt,
data: {
jobType: jobType
},
success: function (data) { success: function (data) {
$(".work-list").empty().html(data); $(".work-list").empty().html(data);
} }
}); });
} }
$("#refresh-list").on('click', function () { $("#refresh-list").on('click', function () {
refreshJobList(); refreshJobList();
}); });
$(".refresh-list-checkbox").on('change', function () { $(".refresh-list-checkbox").on('change', function () {
refreshJobList(); refreshJobList();
}); });
$("#job-type-filter").on('change', function () {
refreshJobList();
});
$(".admintable").on('click', '.change-status-interrupt', function () { $(".admintable").on('click', '.change-status-interrupt', function () {
var workerId = $(this).attr('data-id'); var workerId = $(this).attr('data-id');