Skip to content

Commit 4a0070d

Browse files
authored
Improvements on datetime handling + #38 + #39 (#41)
1 parent 7ca493e commit 4a0070d

28 files changed

Lines changed: 177 additions & 57 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ composer.lock
33
.phpunit.result.cache
44
.php_cs.cache
55
.php_cs
6+
.php-cs-fixer.cache

.php_cs.dist renamed to .php-cs-fixer.dist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
$finder = PhpCsFixer\Finder::create()->in(__DIR__.'/src');
44

5-
return PhpCsFixer\Config::create()
5+
return (new PhpCsFixer\Config())
66
->setRules([
77
'@Symfony' => true,
88
'declare_strict_types' => true,

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@
5353
"minimum-stability": "dev",
5454
"prefer-stable": true,
5555
"config": {
56-
"sort-packages": true
56+
"sort-packages": true,
57+
"allow-plugins": {
58+
"php-http/discovery": true
59+
}
5760
},
5861
"extra": {
5962
"branch-alias": {

src/Controller/DashboardController.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use CodeRhapsodie\EzDataflowBundle\Gateway\ScheduledDataflowGateway;
1313
use Doctrine\DBAL\Query\QueryBuilder;
1414
use eZ\Publish\Core\MVC\Symfony\Security\Authorization\Attribute;
15-
use EzSystems\EzPlatformAdminUi\Notification\NotificationHandlerInterface;
1615
use EzSystems\EzPlatformAdminUiBundle\Controller\Controller;
1716
use Pagerfanta\Adapter\DoctrineDbalAdapter;
1817
use Pagerfanta\Pagerfanta;
@@ -27,15 +26,12 @@ class DashboardController extends Controller
2726
{
2827
/** @var JobGateway */
2928
private $jobGateway;
30-
/** @var NotificationHandlerInterface */
31-
private $notificationHandler;
3229
/** @var ScheduledDataflowGateway */
3330
private $scheduledDataflowGateway;
3431

35-
public function __construct(JobGateway $jobGateway, NotificationHandlerInterface $notificationHandler, ScheduledDataflowGateway $scheduledDataflowGateway)
32+
public function __construct(JobGateway $jobGateway, ScheduledDataflowGateway $scheduledDataflowGateway)
3633
{
3734
$this->jobGateway = $jobGateway;
38-
$this->notificationHandler = $notificationHandler;
3935
$this->scheduledDataflowGateway = $scheduledDataflowGateway;
4036
}
4137

@@ -108,9 +104,11 @@ public function getOneshotPage(Request $request): Response
108104
public function history(Request $request): Response
109105
{
110106
$this->denyAccessUnlessGranted(new Attribute('ezdataflow', 'view'));
107+
$filter = (int) $request->query->get('filter', JobGateway::FILTER_NONE);
111108

112109
return $this->render('@ezdesign/ezdataflow/Dashboard/history.html.twig', [
113-
'pager' => $this->getPager($this->jobGateway->getListQueryForAdmin(), $request),
110+
'pager' => $this->getPager($this->jobGateway->getListQueryForAdmin($filter), $request),
111+
'filter' => $filter,
114112
]);
115113
}
116114

@@ -120,9 +118,11 @@ public function history(Request $request): Response
120118
public function getHistoryPage(Request $request): Response
121119
{
122120
$this->denyAccessUnlessGranted(new Attribute('ezdataflow', 'view'));
121+
$filter = (int) $request->query->get('filter', JobGateway::FILTER_NONE);
123122

124123
return $this->render('@ezdesign/ezdataflow/Dashboard/history.html.twig', [
125-
'pager' => $this->getPager($this->jobGateway->getListQueryForAdmin(), $request),
124+
'pager' => $this->getPager($this->jobGateway->getListQueryForAdmin($filter), $request),
125+
'filter' => $filter,
126126
]);
127127
}
128128

@@ -143,6 +143,7 @@ private function getPager(QueryBuilder $query, Request $request): Pagerfanta
143143
{
144144
$pager = new Pagerfanta(new DoctrineDbalAdapter($query, function ($queryBuilder) {
145145
return $queryBuilder->select('COUNT(DISTINCT id) AS total_results')
146+
->resetQueryPart('orderBy')
146147
->setMaxResults(1);
147148
}));
148149
$pager->setMaxPerPage(20);

src/Controller/JobController.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ public function displayDetails(int $id): Response
5353

5454
/**
5555
* @Route("/details/log/{id}", name="coderhapsodie.ezdataflow.job.log")
56-
*
57-
* @param int $id
58-
*
59-
* @return Response
6056
*/
6157
public function displayLog(int $id): Response
6258
{

src/Controller/ScheduledDataflowController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public function create(Request $request): Response
5858
if ($form->isSubmitted() && $form->isValid()) {
5959
/** @var ScheduledDataflow $newWorkflow */
6060
$newWorkflow = $form->getData();
61-
6261
try {
6362
$this->scheduledDataflowGateway->save($newWorkflow);
6463
$this->notificationHandler->success($this->translator->trans('coderhapsodie.ezdataflow.workflow.create.success'));

src/Core/FieldComparator/AbstractFieldComparator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function compare(Field $field, $hash): bool
2626
}
2727

2828
/**
29-
* Returns true if values are equals, false otherwise
29+
* Returns true if values are equals, false otherwise.
3030
*/
3131
abstract protected function compareValues(Value $currentValue, Value $newValue): bool;
3232
}

src/Exception/InvalidArgumentTypeException.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ class InvalidArgumentTypeException extends \Exception
99
/**
1010
* @param string|array $expectedTypes
1111
* @param mixed $received
12-
*
13-
* @return InvalidArgumentTypeException
1412
*/
1513
public static function create($expectedTypes, $received): self
1614
{

src/Exception/UnknownFieldException.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
class UnknownFieldException extends \Exception
88
{
9-
/**
10-
* @return UnknownFieldException
11-
*/
129
public static function create(string $fieldIdentifier, string $contentTypeIdentifier): self
1310
{
1411
return new self(sprintf(

src/Filter/NotModifiedContentFilter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class NotModifiedContentFilter
2222
/** @var FieldComparatorInterface */
2323
private $comparator;
2424

25-
2625
public function __construct(ContentService $contentService, FieldComparatorInterface $comparator)
2726
{
2827
$this->contentService = $contentService;
@@ -43,20 +42,21 @@ public function __invoke($data)
4342

4443
foreach ($data->getFields() as $identifier => $hash) {
4544
$field = $content->getField($identifier, $data->getLanguageCode());
46-
if ($field === null || !$this->comparator->compare($field, $hash)) {
45+
if (null === $field || !$this->comparator->compare($field, $hash)) {
4746
// At least one field is different, continue the dataflow.
4847
return $data;
4948
}
5049
}
5150

5251
// All fields are identical, filter this item out.
5352
$this->log('info', 'Not modified content skipped', ['id' => $data->getId(), 'remote_id' => $data->getRemoteId()]);
53+
5454
return false;
5555
}
5656

5757
private function log(string $level, string $message, array $context = [])
5858
{
59-
if ($this->logger === null) {
59+
if (null === $this->logger) {
6060
return;
6161
}
6262
$this->logger->log($level, $message, $context);

0 commit comments

Comments
 (0)