From f4bf6b9fa456a50f8403107d527a012b45171dae Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 27 Jun 2023 13:14:53 +0300 Subject: [PATCH] fix crawl queue message --- library/mysql.php | 17 +++++++++++++++++ public/explore.php | 2 +- public/search.php | 4 ++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/library/mysql.php b/library/mysql.php index d9bebf2..6c7d28a 100644 --- a/library/mysql.php +++ b/library/mysql.php @@ -163,6 +163,7 @@ class MySQL { return $query->fetch()->total; } + /* not in use public function getTotalPagesByHttpCode(mixed $httpCode) { if (is_null($httpCode)) { @@ -179,6 +180,7 @@ class MySQL { return $query->fetch()->total; } + */ public function getHostPage(int $hostId, int $crc32uri) { @@ -662,6 +664,21 @@ class MySQL { return $query->fetchAll(); } + public function getHostPageCrawlQueueTotal(int $timeFrom) { + + $query = $this->_db->prepare('SELECT COUNT(*) AS `total` + + FROM `hostPage` + JOIN `host` ON (`host`.`hostId` = `hostPage`.`hostId`) + + WHERE (`hostPage`.`timeUpdated` IS NULL OR `hostPage`.`timeUpdated` < ? ) AND `host`.`status` <> ? + AND `hostPage`.`timeBanned` IS NULL'); + + $query->execute([$timeFrom, 0]); + + return $query->fetch()->total; + } + public function updateHostPageCrawlQueue(int $hostPageId, int $timeUpdated, int $httpCode, int $size) { $query = $this->_db->prepare('UPDATE `hostPage` SET `timeUpdated` = ?, `httpCode` = ?, `size` = ? WHERE `hostPageId` = ? LIMIT 1'); diff --git a/public/explore.php b/public/explore.php index 4cb3a12..a959c70 100644 --- a/public/explore.php +++ b/public/explore.php @@ -274,7 +274,7 @@ $placeholder = Filter::plural($totalPages, [sprintf(_('Over %s page or enter the
- getTotalPagesByHttpCode(null)) { ?> + getHostPageCrawlQueueTotal(time() - CRAWL_PAGE_SECONDS_OFFSET)) { ?>
diff --git a/public/search.php b/public/search.php index 5b73f41..37cdacb 100644 --- a/public/search.php +++ b/public/search.php @@ -321,7 +321,7 @@ if (filter_var($q, FILTER_VALIDATE_URL) && preg_match(CRAWL_URL_REGEXP, $q)) {
- getTotalPagesByHttpCode(null)) { ?> + getHostPageCrawlQueueTotal(time() - CRAWL_PAGE_SECONDS_OFFSET)) { ?>
@@ -391,7 +391,7 @@ if (filter_var($q, FILTER_VALIDATE_URL) && preg_match(CRAWL_URL_REGEXP, $q)) {
- getTotalPagesByHttpCode(null)) { ?> + getHostPageCrawlQueueTotal(time() - CRAWL_PAGE_SECONDS_OFFSET)) { ?>