Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHRAS-3995: Admin - worker - job queue - average duration #4448

Merged
merged 5 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public function findByFilter(array $status, $jobType, $databoxId, $recordId, $fi
return $q->getResult();
}

public function getJobCount(array $status, $jobType, $databoxId, $recordId)
public function getJobCount(array $status, $jobType, $databoxId, $recordId, $fieldTimeFilter, $dateTimeFilter = null)
{
$qb = $this->createQueryBuilder('w');
$qb->select('count(w)');
Expand All @@ -476,6 +476,12 @@ public function getJobCount(array $status, $jobType, $databoxId, $recordId)
->setParameter('recordId', $recordId);
}

if ($dateTimeFilter instanceof DateTime) {
// published or created column
$qb->andWhere('w.' .$fieldTimeFilter. ' >= :dateTimeFilter')
->setParameter('dateTimeFilter', $dateTimeFilter->format('Y-m-d H:i:s'));
}

return $qb->getQuery()->getSingleScalarResult();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,12 @@ public function infoAction(PhraseaApplication $app, Request $request)
$helpers = new PhraseanetExtension($this->app);

$workerRunningJob = $repoWorker->findByFilter($filterStatus, $jobType, $databoxId, $recordId, $fieldTimeFilter, $dateTimeFilter);
$workerRunningJobTotalCount = $repoWorker->getJobCount($filterStatus, $jobType, $databoxId, $recordId);
$workerRunningJobTotalCount = $repoWorker->getJobCount($filterStatus, $jobType, $databoxId, $recordId, $fieldTimeFilter, $dateTimeFilter);
$workerRunningJobTotalCount = number_format($workerRunningJobTotalCount, 0, '.', ' ');
$totalDuration = array_sum(array_column($workerRunningJob, 'duration'));

$averageDuration = (count($workerRunningJob) == 0) ? 0 : $totalDuration/(float)count($workerRunningJob);

// format duration
$totalDuration = $helpers->getDuration($totalDuration);

Expand All @@ -159,7 +162,7 @@ public function infoAction(PhraseaApplication $app, Request $request)
$realEntryDuration = $helpers->getDuration($realEntryDuration);

// get all row count in the table WorkerRunningJob
$totalCount = $repoWorker->getJobCount([], null, null , null);
$totalCount = $repoWorker->getJobCount([], null, null , null, null, null);
$totalCount = number_format($totalCount, 0, '.', ' ');

$databoxIds = array_map(function (\databox $databox) {
Expand All @@ -186,6 +189,7 @@ public function infoAction(PhraseaApplication $app, Request $request)
'resultTotal' => $workerRunningJobTotalCount,
'totalCount' => $totalCount,
'totalDuration' => $totalDuration,
'averageDuration' => number_format($averageDuration, 2, '.', ' ') . ' s',
'realEntryDuration'=> $realEntryDuration
]);
} else {
Expand All @@ -198,6 +202,7 @@ public function infoAction(PhraseaApplication $app, Request $request)
'resultTotal' => $workerRunningJobTotalCount,
'totalCount' => $totalCount,
'totalDuration' => $totalDuration,
'averageDuration' => number_format($averageDuration, 2, '.', ' ') . ' s',
'realEntryDuration'=> $realEntryDuration
]);
}
Expand Down
377 changes: 192 additions & 185 deletions resources/locales/messages.de.xlf

Large diffs are not rendered by default.

317 changes: 162 additions & 155 deletions resources/locales/messages.en.xlf

Large diffs are not rendered by default.

305 changes: 156 additions & 149 deletions resources/locales/messages.fr.xlf

Large diffs are not rendered by default.

291 changes: 149 additions & 142 deletions resources/locales/messages.nl.xlf

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/locales/validators.de.xlf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?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">
<file date="2023-11-29T15:09:52Z" source-language="en" target-language="de" datatype="plaintext" original="not.available">
<file date="2023-12-19T11:58:47Z" source-language="en" target-language="de" datatype="plaintext" original="not.available">
<header>
<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>
Expand Down
2 changes: 1 addition & 1 deletion resources/locales/validators.en.xlf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?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">
<file date="2023-11-29T15:10:09Z" source-language="en" target-language="en" datatype="plaintext" original="not.available">
<file date="2023-12-19T11:59:03Z" source-language="en" target-language="en" datatype="plaintext" original="not.available">
<header>
<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>
Expand Down
2 changes: 1 addition & 1 deletion resources/locales/validators.fr.xlf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?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">
<file date="2023-11-29T15:10:28Z" source-language="en" target-language="fr" datatype="plaintext" original="not.available">
<file date="2023-12-19T11:59:23Z" source-language="en" target-language="fr" datatype="plaintext" original="not.available">
<header>
<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>
Expand Down
2 changes: 1 addition & 1 deletion resources/locales/validators.nl.xlf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?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">
<file date="2023-11-29T15:10:50Z" source-language="en" target-language="nl" datatype="plaintext" original="not.available">
<file date="2023-12-19T11:59:46Z" source-language="en" target-language="nl" datatype="plaintext" original="not.available">
<header>
<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>
Expand Down
5 changes: 5 additions & 0 deletions templates/web/admin/worker-manager/worker_info.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@
<span class="result-count" style="margin-left: 40px;">{{ resultCount }} / {{ resultTotal }}</span> <span style="margin-left: 10px;">{{ "job::tab results" | trans }}</span>
</span>

<span class="pull-right" style="margin-top: 5px;margin-right: 20px;">
<span class="average-duration" style="margin-left: 40px;">{{ averageDuration }}</span> <span style="margin-left: 10px;">{{ "job::tab average duration" | trans }}</span>
</span>

<span class="pull-right" style="margin-top: 5px;margin-right: 20px;">
<span class="total-duration" style="margin-left: 40px;">{{ totalDuration }}</span> <span style="margin-left: 10px;">{{ "job::tab total duration" | trans }}</span>
</span>
Expand Down Expand Up @@ -202,6 +206,7 @@
$(".result-count").empty().text(data.resultCount + ' / ' + data.resultTotal);
$(".total-count").empty().text(data.totalCount);
$(".total-duration").empty().text(data.totalDuration);
$(".average-duration").empty().text(data.averageDuration);
$(".real-entry-duration").empty().text(data.realEntryDuration);
}
});
Expand Down