From e435577026e42ba59372f9fc38da8106eb5765de Mon Sep 17 00:00:00 2001 From: Paul Kolbovich Date: Sun, 30 May 2021 18:24:31 +0300 Subject: [PATCH 1/2] [debug:database:log] respect limit and offset command options --- src/Command/Database/DatabaseLogBase.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Command/Database/DatabaseLogBase.php b/src/Command/Database/DatabaseLogBase.php index 075ca661e..7ede8dfa4 100644 --- a/src/Command/Database/DatabaseLogBase.php +++ b/src/Command/Database/DatabaseLogBase.php @@ -182,7 +182,19 @@ protected function makeQuery($offset = null, $range = 1000) $query->orderBy('wid', 'ASC'); - if ($offset) { + if ($this->limit) { + $range = $this->limit; + } + + if ($this->limit && $offset === null) { + if ($this->offset) { + $offset = $this->offset; + } else { + $offset = 0; + } + } + + if ($offset !== null) { $query->range($offset, $range); } From e36326565b29424f79b588830e828a981edc939b Mon Sep 17 00:00:00 2001 From: Paul Kolbovich Date: Sun, 30 May 2021 19:00:16 +0300 Subject: [PATCH 2/2] [debug:database:log] refactoring --- src/Command/Database/DatabaseLogBase.php | 12 ------------ src/Command/Debug/DatabaseLogCommand.php | 10 +++++++++- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/Command/Database/DatabaseLogBase.php b/src/Command/Database/DatabaseLogBase.php index 7ede8dfa4..182d9b117 100644 --- a/src/Command/Database/DatabaseLogBase.php +++ b/src/Command/Database/DatabaseLogBase.php @@ -182,18 +182,6 @@ protected function makeQuery($offset = null, $range = 1000) $query->orderBy('wid', 'ASC'); - if ($this->limit) { - $range = $this->limit; - } - - if ($this->limit && $offset === null) { - if ($this->offset) { - $offset = $this->offset; - } else { - $offset = 0; - } - } - if ($offset !== null) { $query->range($offset, $range); } diff --git a/src/Command/Debug/DatabaseLogCommand.php b/src/Command/Debug/DatabaseLogCommand.php index 10d69b85f..eaaf1f6a5 100644 --- a/src/Command/Debug/DatabaseLogCommand.php +++ b/src/Command/Debug/DatabaseLogCommand.php @@ -149,7 +149,15 @@ private function getEventDetails() */ private function getAllEvents() { - $query = $this->makeQuery(); + if (!$this->offset) { + $this->offset = 0; + } + + if (!$this->limit) { + $this->limit = 1000; + } + + $query = $this->makeQuery($this->offset, $this->limit); $result = $query->execute();