Skip to content

Commit c8f9ec6

Browse files
committed
ACP2E-3189: small improvements and code formatting
1 parent 32f99ce commit c8f9ec6

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

app/code/Magento/Sales/Model/ResourceModel/Report/Bestsellers.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private function clearByDateRange($from = null, $to = null): void
178178
* @param string $table
179179
* @param ?string $from
180180
* @param ?string $to
181-
* @param null|\Magento\Framework\DB\Select|string $subSelect
181+
* @param null|Select|string $subSelect
182182
* @return void
183183
*/
184184
private function clearTableRanges($table, $from = null, $to = null, $subSelect = null): void
@@ -190,8 +190,8 @@ private function clearTableRanges($table, $from = null, $to = null, $subSelect =
190190

191191
if ($subSelect !== null) {
192192
$dataRange = $this->getRange($subSelect);
193-
$deleteCondition = $this->getConnection()->prepareSqlCondition('period', ['in' => $dataRange]);
194-
$this->getConnection()->delete($table, $deleteCondition);
193+
$deleteCondition = $this->getConnection()->prepareSqlCondition('period', ['in' => $dataRange]);
194+
$this->getConnection()->delete($table, $deleteCondition);
195195
return;
196196
} else {
197197
$condition = [];
@@ -210,22 +210,17 @@ private function clearTableRanges($table, $from = null, $to = null, $subSelect =
210210
/**
211211
* Get dates range to clear the table
212212
*
213-
* @param \Magento\Framework\DB\Select $select
214-
* @return array|false
213+
* @param Select $select
214+
* @return array
215215
*/
216-
private function getRange(\Magento\Framework\DB\Select $select)
216+
private function getRange(Select $select): array
217217
{
218218
$connection = $this->getConnection();
219+
$range = [];
219220
try {
220-
$range = [];
221-
222221
$query = $connection->query($select);
223-
224-
while (true == ($date = $query->fetchColumn())) {
225-
$range[] = $date;
226-
}
222+
$range = $query->fetchAll(\Zend_Db::FETCH_COLUMN);
227223
} catch (\Exception $e) {
228-
$range = false;
229224
}
230225
return $range;
231226
}

0 commit comments

Comments
 (0)