From 124cef30588aba41dbed6b8f8a05e37adc1af9cd Mon Sep 17 00:00:00 2001 From: yggverse Date: Sun, 14 Apr 2024 15:59:20 +0300 Subject: [PATCH] remove extra namespace --- src/Entity/Tab/Page.php | 6 +++--- src/Model/Database.php | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Entity/Tab/Page.php b/src/Entity/Tab/Page.php index b066d2be..c625058b 100644 --- a/src/Entity/Tab/Page.php +++ b/src/Entity/Tab/Page.php @@ -48,7 +48,7 @@ class Page // Run database cleaner if ($this->config->history->timeout) { - $this->app->database->cleanPageHistory( + $this->app->database->cleanHistory( $this->config->history->timeout ); } @@ -373,7 +373,7 @@ class Page } // Ignore history record on same URL stored in DB - if ($result = $this->app->database->getPageHistory(0, 1)) + if ($result = $this->app->database->getHistory(0, 1)) { if ($url == $result[0]->url) { @@ -396,7 +396,7 @@ class Page // Update history in the database if ($this->config->history->enabled) { - $this->app->database->addPageHistory( + $this->app->database->addHistory( $url ); } diff --git a/src/Model/Database.php b/src/Model/Database.php index 22b1639e..1c4be565 100644 --- a/src/Model/Database.php +++ b/src/Model/Database.php @@ -35,7 +35,7 @@ class Database ); $this->_database->query(' - CREATE TABLE IF NOT EXISTS "pageHistory" + CREATE TABLE IF NOT EXISTS "history" ( "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "time" INTEGER NOT NULL, @@ -55,12 +55,12 @@ class Database } } - public function addPageHistory( + public function addHistory( string $url ): int { $query = $this->_database->prepare( - 'INSERT INTO `pageHistory` (`time`, `url`) VALUES (:time, :url)' + 'INSERT INTO `history` (`time`, `url`) VALUES (:time, :url)' ); $query->execute( @@ -73,14 +73,14 @@ class Database return (int) $this->_database->lastInsertId(); } - public function getPageHistory( + public function getHistory( int $start = 0, int $limit = 1000 ): array { $query = $this->_database->query( sprintf( - 'SELECT * FROM `pageHistory` ORDER BY `id` DESC LIMIT %d,%d', + 'SELECT * FROM `history` ORDER BY `id` DESC LIMIT %d,%d', $start, $limit ) @@ -90,13 +90,13 @@ class Database return $query->fetchAll(); } - public function cleanPageHistory( + public function cleanHistory( int $timeout = 0 ): int { $query = $this->_database->query( sprintf( - 'DELETE FROM `pageHistory` WHERE `time` + %d < %d', + 'DELETE FROM `history` WHERE `time` + %d < %d', $timeout, time() )