]> _ Git - fluidbook-toolbox.git/commitdiff
wip #7819
authorsoufiane <soufiane@cubedesigners.com>
Mon, 3 Nov 2025 18:21:16 +0000 (19:21 +0100)
committersoufiane <soufiane@cubedesigners.com>
Mon, 3 Nov 2025 18:21:16 +0000 (19:21 +0100)
app/Console/Commands/AddFluidbookHemsleyToCollection.php [new file with mode: 0644]
app/Console/Commands/AuditLink.php
app/Console/Commands/addFluidbookHemsleyToCollection.php [deleted file]
app/Jobs/AuditLink.php

diff --git a/app/Console/Commands/AddFluidbookHemsleyToCollection.php b/app/Console/Commands/AddFluidbookHemsleyToCollection.php
new file mode 100644 (file)
index 0000000..59ce4f5
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Console\Commands\Base\ToolboxCommand;
+use App\Models\FluidbookCollection;
+use App\Models\FluidbookAuditLink;
+use App\Models\FluidbookPublication;
+
+class AddFluidbookHemsleyToCollection extends ToolboxCommand
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'fluidbook:fill-hemsley-collection {--sync}';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '';
+
+    /**
+     * Execute the console command.
+     */
+    public function handle()
+    {
+        //
+        $data = FluidbookPublication::getFluidbooksHemsley();
+        FluidbookCollection::updateHemsleyCollection($data);
+    }
+}
index 140c91d384e26ba68f4f0747cbe3e0638b5bf950..97c7ff85609f38c8ba7e1e38e558cc53eb771940 100644 (file)
@@ -30,6 +30,5 @@ class AuditLink extends ToolboxCommand
         //
         $c = FluidbookCollection::find($this->argument('id'));
         $c->runAuditLink($this->option('sync', false));
-        //$f->generateThumbnailsPreview($this->option('sync', false));
     }
 }
diff --git a/app/Console/Commands/addFluidbookHemsleyToCollection.php b/app/Console/Commands/addFluidbookHemsleyToCollection.php
deleted file mode 100644 (file)
index f9bd9ca..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-
-namespace App\Console\Commands;
-
-use App\Console\Commands\Base\ToolboxCommand;
-use App\Models\FluidbookCollection;
-use App\Models\FluidbookAuditLink;
-use App\Models\FluidbookPublication;
-
-class addFluidbookHemsleyToCollection extends ToolboxCommand
-{
-    /**
-     * The name and signature of the console command.
-     *
-     * @var string
-     */
-    protected $signature = 'fluidbook:fill-hemsley-collection {--sync}';
-
-    /**
-     * The console command description.
-     *
-     * @var string
-     */
-    protected $description = '';
-
-    /**
-     * Execute the console command.
-     */
-    public function handle()
-    {
-        //
-        //$f->generateThumbnailsPreview($this->option('sync', false));
-        $data = FluidbookPublication::getFluidbooksHemsley();
-        FluidbookCollection::updateHemsleyCollection($data);
-    }
-}
index 0a2d35a530d4d655adfea32f641d40cb8b5bbed9..e1dcb3d9ac2eb9ea500dbfd452f5133f2e6ce364 100644 (file)
@@ -42,14 +42,15 @@ class AuditLink extends Base
                 // Error code start with 4 or 5
                 // Redirection code start with 3
                 $httpCode = FluidbookAuditLink::getHttpCode($link['to']);
+                $comment = FluidbookAuditLink::getHttpCodeComment($httpCode);
 
                 $externalLinks[] = [
+                    'link_id' => $link['uid'],
                     'fluidbook_id' => intval($publication['fluidbook']),
                     'page' => intval($link['page']),
-                    'link_id' => $link['uid'],
-                    'error_code' => str_starts_with($httpCode, 4) || str_starts_with($httpCode, 5) ? $httpCode : "",
-                    'first_time_error' => '', // Datetime of the first time we saw this error
-                    'last_date_test' => time(),
+                    'error_code' => str_starts_with($httpCode, 4) || str_starts_with($httpCode, 5) ? $httpCode.$comment : "",
+                    'first_time_error' => "", // Datetime of the first time we saw this error
+                    'last_date_test' => date('Y-m-d H:i:s'),
                     'url' => $link['to'],
                     'new_url' => '',
                     'redirection_code' => str_starts_with($httpCode, 3) ? $httpCode : "",
@@ -61,7 +62,7 @@ class AuditLink extends Base
             }
         }
 
-        $audit = FluidbookAuditLink::insert($externalLinks);
+        FluidbookAuditLink::updateOrCreate($externalLinks);
 
         Log::info('Job exécuté avec succès');
     }