Skip to content

Commit 9507a39

Browse files
committed
Added error count columns to job tables
1 parent 131045a commit 9507a39

6 files changed

Lines changed: 54 additions & 9 deletions

File tree

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@
4242
},
4343
"require": {
4444
"php": "^7.3||^8.0",
45+
"ext-json": "*",
4546
"code-rhapsodie/dataflow-bundle": "^3.0||^4.0",
4647
"ezsystems/ezplatform-admin-ui": "^2.3",
47-
"ezsystems/ezplatform-kernel": "^1.3"
48+
"ezsystems/ezplatform-kernel": "^1.3",
49+
"http-interop/http-factory-guzzle": "^1.2"
4850
},
4951
"require-dev": {
5052
"phpunit/phpunit": "^7||^8||^9",

src/Controller/DashboardController.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use CodeRhapsodie\DataflowBundle\Entity\ScheduledDataflow;
99
use CodeRhapsodie\EzDataflowBundle\Form\CreateOneshotType;
1010
use CodeRhapsodie\EzDataflowBundle\Form\CreateScheduledType;
11+
use CodeRhapsodie\EzDataflowBundle\Gateway\ExceptionJSONDecoderAdapter;
1112
use CodeRhapsodie\EzDataflowBundle\Gateway\JobGateway;
1213
use CodeRhapsodie\EzDataflowBundle\Gateway\ScheduledDataflowGateway;
1314
use Doctrine\DBAL\Query\QueryBuilder;
@@ -141,11 +142,15 @@ public function getHistoryForScheduled(Request $request, int $id): Response
141142

142143
private function getPager(QueryBuilder $query, Request $request): Pagerfanta
143144
{
144-
$pager = new Pagerfanta(new DoctrineDbalAdapter($query, function ($queryBuilder) {
145-
return $queryBuilder->select('COUNT(DISTINCT id) AS total_results')
146-
->resetQueryPart('orderBy')
147-
->setMaxResults(1);
148-
}));
145+
$pager = new Pagerfanta(
146+
new ExceptionJSONDecoderAdapter(
147+
new DoctrineDbalAdapter($query, function ($queryBuilder) {
148+
return $queryBuilder->select('COUNT(DISTINCT id) AS total_results')
149+
->resetQueryPart('orderBy')
150+
->setMaxResults(1);
151+
})
152+
)
153+
);
149154
$pager->setMaxPerPage(20);
150155
$pager->setCurrentPage($request->query->get('page', 1));
151156

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CodeRhapsodie\EzDataflowBundle\Gateway;
6+
7+
use Pagerfanta\Adapter\AdapterInterface;
8+
9+
class ExceptionJSONDecoderAdapter implements AdapterInterface
10+
{
11+
/** @var AdapterInterface */
12+
private $adapter;
13+
14+
public function __construct(AdapterInterface $adapter)
15+
{
16+
$this->adapter = $adapter;
17+
}
18+
19+
public function getNbResults()
20+
{
21+
return $this->adapter->getNbResults();
22+
}
23+
24+
public function getSlice($offset, $length)
25+
{
26+
$slice = $this->adapter->getSlice($offset, $length);
27+
array_walk($slice, static function (&$value) {
28+
if (isset($value['exceptions'])) {
29+
$value['exceptions'] = json_decode($value['exceptions'], true, 512, JSON_THROW_ON_ERROR);
30+
}
31+
});
32+
33+
return $slice;
34+
}
35+
}

src/Resources/translations/messages.en.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ coderhapsodie.ezdataflow.history.title: History
2020
coderhapsodie.ezdataflow.history.list.title: 'Executions list'
2121
coderhapsodie.ezdataflow.history.list.name: Name
2222
coderhapsodie.ezdataflow.history.list.request: 'Requested on'
23-
coderhapsodie.ezdataflow.history.list.count: 'Items count'
24-
coderhapsodie.ezdataflow.history.list.error_count: 'Errors count'
23+
coderhapsodie.ezdataflow.history.list.count: 'Number of successes'
24+
coderhapsodie.ezdataflow.history.list.errors: 'Number of errors'
2525
coderhapsodie.ezdataflow.history.list.start: 'Started on'
2626
coderhapsodie.ezdataflow.history.list.end: 'Finished on'
2727
coderhapsodie.ezdataflow.history.list.view: 'View details'

src/Resources/translations/messages.fr.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ coderhapsodie.ezdataflow.history.title: Historique
2020
coderhapsodie.ezdataflow.history.list.title: 'Liste des exécutions'
2121
coderhapsodie.ezdataflow.history.list.name: Nom
2222
coderhapsodie.ezdataflow.history.list.request: 'Demandé le'
23-
coderhapsodie.ezdataflow.history.list.count: 'Nombre d''objets'
23+
coderhapsodie.ezdataflow.history.list.count: 'Nombre de succès'
24+
coderhapsodie.ezdataflow.history.list.errors: 'Nombre d''erreurs'
2425
coderhapsodie.ezdataflow.history.list.start: 'Commencé le'
2526
coderhapsodie.ezdataflow.history.list.end: 'Terminé le'
2627
coderhapsodie.ezdataflow.history.list.view: 'Voir le détail'

src/Resources/views/themes/admin/ezdataflow/parts/tab/job_list.html.twig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<th>{{ 'coderhapsodie.ezdataflow.history.list.name'|trans }}</th>
1818
<th>{{ 'coderhapsodie.ezdataflow.history.list.request'|trans }}</th>
1919
<th>{{ 'coderhapsodie.ezdataflow.history.list.count'|trans }}</th>
20+
<th>{{ 'coderhapsodie.ezdataflow.history.list.errors'|trans }}</th>
2021
<th>{{ 'coderhapsodie.ezdataflow.history.list.start'|trans }}</th>
2122
<th>{{ 'coderhapsodie.ezdataflow.history.list.end'|trans }}</th>
2223
<th>{{ 'coderhapsodie.ezdataflow.history.list.status'|trans }}</th>
@@ -29,6 +30,7 @@
2930
<td>{{ job.label }}</td>
3031
<td>{{ date(job.requested_date)|ez_short_datetime }}</td>
3132
<td>{{ job.count|default('') }}</td>
33+
<td>{{ job.exceptions|length }}</td>
3234
<td>{{ job.start_time ? date(job.start_time)|ez_short_datetime : '' }}</td>
3335
<td>{{ job.end_time ? date(job.end_time)|ez_short_datetime : '' }}</td>
3436
<td>{{ macros.translateStatus(job.status) }}</td>

0 commit comments

Comments
 (0)