]> _ Git - fluidbook-toolbox.git/commitdiff
wip #7868 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 9 Feb 2026 11:42:14 +0000 (12:42 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 9 Feb 2026 11:42:14 +0000 (12:42 +0100)
app/Jobs/AuditLink.php

index 51bc860ddb0be6eb1fdcd0dbcc063a6bfabacdda..ba850574d13d98fd96284382edb338427cb79926 100644 (file)
@@ -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();