From: Vincent Vanwaelscappel Date: Mon, 9 Feb 2026 11:42:14 +0000 (+0100) Subject: wip #7868 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=a29b0ffcd1faa17b9852f403c3bb7f9b40e63835;p=fluidbook-toolbox.git wip #7868 @0.5 --- diff --git a/app/Jobs/AuditLink.php b/app/Jobs/AuditLink.php index 51bc860dd..ba850574d 100644 --- a/app/Jobs/AuditLink.php +++ b/app/Jobs/AuditLink.php @@ -13,26 +13,33 @@ use Cubist\Net\HTTP; class AuditLink extends Base { protected $_batchSize = 500; - protected static $minTimeBetweenRequests = 10; + protected $_url = null; + protected static $minTimeBetweenRequests = 2; /** * Create a new job instance. */ - public function __construct($batchSize = 500) + public function __construct($batchSize = 500, $url = null) { $this->_batchSize = $batchSize; + $this->_url = $url; } public function handle() { - $urls = []; - foreach (FluidbookAuditLink::orderBy('updated_at', 'asc')->get() as $link) { - if (!isset($urls[$link->url])) { - $urls[$link->url] = $link->http_code ?? 0; + if (null == $this->_url) { + $urls = []; + foreach (FluidbookAuditLink::orderBy('updated_at', 'asc')->get() as $link) { + if (!isset($urls[$link->url])) { + $urls[$link->url] = $link->http_code ?? 0; + } } + $urls = array_slice($urls, 0, $this->_batchSize, true); + ArrayUtil::shuffle($urls); + } else { + $urls = [$this->_url => 200]; } - $urls = array_slice($urls, 0, $this->_batchSize, true); - ArrayUtil::shuffle($urls); + HTTP::setCookieFile(Files::mkdir(protected_path('fluidbookpublication/linkaudit')) . 'cookies.txt'); @@ -65,6 +72,7 @@ class AuditLink extends Base } else { $res = HTTP::getResponseCode($url, 10, 'http://paris.cubedesigners.com:8191/v1'); } + Log::info('Tested ' . $url . ': ' . $res['http_code']); if ($res['http_code'] != $previousCode) { $res['code_date'] = new \DateTime();