Skip to content

Commit 36e0cdd

Browse files
Siarhei AndreyeuSiarhei Andreyeu
authored andcommitted
MAGNIMEX-13: Import History
-Fix report time
1 parent 259ceb6 commit 36e0cdd

File tree

2 files changed

+8
-38
lines changed

2 files changed

+8
-38
lines changed

app/code/Magento/ImportExport/Helper/Report.php

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,23 @@
1717
class Report extends \Magento\Framework\App\Helper\AbstractHelper
1818
{
1919
/**
20-
* @var \Magento\Framework\Stdlib\DateTime\DateTime
20+
* @var \Magento\Framework\Stdlib\DateTime\TimeZone
2121
*/
22-
protected $dateTime;
22+
protected $timeZone;
2323

2424
/**
2525
* Construct
2626
*
2727
* @param \Magento\Framework\App\Helper\Context $context
28-
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
28+
* @param \Magento\Framework\Stdlib\DateTime\TimeZone $timeZone
29+
* @param \Magento\Framework\Filesystem $filesystem
2930
*/
3031
public function __construct(
3132
\Magento\Framework\App\Helper\Context $context,
32-
\Magento\Framework\Stdlib\DateTime\DateTime $dateTime,
33+
\Magento\Framework\Stdlib\DateTime\TimeZone $timeZone,
3334
\Magento\Framework\Filesystem $filesystem
3435
) {
35-
$this->dateTime = $dateTime;
36+
$this->timeZone = $timeZone;
3637
$this->filesystem = $filesystem;
3738
$this->varDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
3839
parent::__construct($context);
@@ -46,8 +47,8 @@ public function __construct(
4647
*/
4748
public function getExecutionTime($time)
4849
{
49-
$reportTime = new \DateTime($this->dateTime->date($time));
50-
$timeDiff = $reportTime->diff(new \DateTime($this->dateTime->date()));
50+
$reportTime = $this->timeZone->date($time, $this->timeZone->getConfigTimezone());
51+
$timeDiff = $reportTime->diff($this->timeZone->date());
5152
return $timeDiff->format('%H:%M:%S');
5253
}
5354

@@ -68,32 +69,6 @@ public function getSummaryStats(\Magento\ImportExport\Model\Import $import)
6869
return $message;
6970
}
7071

71-
/**
72-
* Check if import process failed is failed by maximum execution time
73-
*
74-
* @param string $time
75-
* @return bool
76-
*/
77-
public function isFailed($time)
78-
{
79-
$isFailed = false;
80-
if ($this->getTimeDiff($time) > History::MAX_IMPORT_EXECUTION_TIME) {
81-
$isFailed = true;
82-
}
83-
return $isFailed;
84-
}
85-
86-
/**
87-
* Get time difference
88-
*
89-
* @param string $time
90-
* @return int
91-
*/
92-
protected function getTimeDiff($time)
93-
{
94-
return $this->dateTime->timestamp($time) - $this->dateTime->timestamp();
95-
}
96-
9772
/**
9873
* Checks imported file exists.
9974
*

app/code/Magento/ImportExport/Model/History.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ class History extends \Magento\Framework\Model\AbstractModel
3333

3434
const IMPORT_FAILED = 'Failed';
3535

36-
/**
37-
* Maximum execution time for import process in seconds
38-
*/
39-
const MAX_IMPORT_EXECUTION_TIME = 21600;
40-
4136
/**
4237
* @var \Magento\ImportExport\Helper\Report
4338
*/

0 commit comments

Comments
 (0)