Commit d11970b3 authored by Chivy Lim's avatar Chivy Lim

[TASK] Correct importing queue order

refs KIME-3603
parent 24a4c578
...@@ -54,7 +54,7 @@ class SpreadsheetImportCommandController extends CommandController { ...@@ -54,7 +54,7 @@ class SpreadsheetImportCommandController extends CommandController {
$this->quit(); $this->quit();
} }
/** @var SpreadsheetImport $spreadsheetImport */ /** @var SpreadsheetImport $spreadsheetImport */
$spreadsheetImport = $this->spreadsheetImportRepository->findOneByImportingStatus(SpreadsheetImport::IMPORTING_STATUS_IN_QUEUE); $spreadsheetImport = $this->spreadsheetImportRepository->findPreviousOneInQueue();
if ($spreadsheetImport instanceof SpreadsheetImport) { if ($spreadsheetImport instanceof SpreadsheetImport) {
// mark importing status as "Progressing" before continuing the importing // mark importing status as "Progressing" before continuing the importing
$spreadsheetImport->setImportingStatus(SpreadsheetImport::IMPORTING_STATUS_IN_PROGRESS); $spreadsheetImport->setImportingStatus(SpreadsheetImport::IMPORTING_STATUS_IN_PROGRESS);
......
...@@ -12,7 +12,9 @@ namespace WE\SpreadsheetImport\Domain\Repository; ...@@ -12,7 +12,9 @@ namespace WE\SpreadsheetImport\Domain\Repository;
* */ * */
use TYPO3\Flow\Annotations as Flow; use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Persistence\QueryInterface;
use TYPO3\Flow\Persistence\Repository; use TYPO3\Flow\Persistence\Repository;
use WE\SpreadsheetImport\Domain\Model\SpreadsheetImport;
/** /**
* @Flow\Scope("singleton") * @Flow\Scope("singleton")
...@@ -22,7 +24,21 @@ class SpreadsheetImportRepository extends Repository { ...@@ -22,7 +24,21 @@ class SpreadsheetImportRepository extends Repository {
/** /**
* @var array * @var array
*/ */
protected $defaultOrderings = array('scheduleDate' => \TYPO3\Flow\Persistence\QueryInterface::ORDER_ASCENDING); protected $defaultOrderings = array('scheduleDate' => QueryInterface::ORDER_DESCENDING);
/**
* @return SpreadsheetImport
*/
public function findPreviousOneInQueue() {
$query = $this->createQuery();
$constraint = $query->logicalAnd(
$query->equals('importingStatus', SpreadsheetImport::IMPORTING_STATUS_IN_QUEUE),
$query->lessThanOrEqual('scheduleDate', new \DateTime())
);
return $query->matching($constraint)
->setOrderings(array('scheduleDate' => QueryInterface::ORDER_ASCENDING))
->execute()->getFirst();
}
/** /**
* @param \DateTime $dateTime * @param \DateTime $dateTime
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment