]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6237 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 1 Sep 2023 15:06:41 +0000 (17:06 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 1 Sep 2023 15:06:41 +0000 (17:06 +0200)
app/Console/Kernel.php
app/Fluidbook/Farm.php
resources/linkeditor/js/linkeditor.rulers.js

index 13bc9d28f14e3e3371a8307f5808f79c1e36dce9..1396ff70f1885e3eb49c186c3ef7b42aea0cf442 100644 (file)
@@ -36,7 +36,7 @@ class Kernel extends \Cubist\Backpack\Console\Kernel
             $schedule->command('job:dispatchNow Maintenance\\\\RemoveDuplicates')->monthly();
             // WS to Toolbox migration
             $schedule->command('ws:migrate --publications=v2 --documents=missing')->dailyAt('1:00');
-            $schedule->command('ws:migrate --publications=missing --documents=missing')->everyFifteenMinutes();
+            $schedule->command('ws:migrate --publications=missing --documents=missing')->everyTwoHours();
             $schedule->command('fluidbook:quote --reminder')->weekdays()->at('10:00');
         }
 
@@ -46,7 +46,7 @@ class Kernel extends \Cubist\Backpack\Console\Kernel
 
         $schedule->command('fluidbook:farm:ping')->everyMinute();
         $schedule->command('cubist:magic:precache')->everyFiveMinutes();
-        $schedule->command('toolbox:precache')->everyFifteenMinutes();
+        $schedule->command('toolbox:precache')->everyFiveMinutes();
     }
 
     /**
index c3c6926ec8517ab67f62707754f4c1a3804e4f09..40db9f62678525ed29121416011ab46d65256e41 100644 (file)
@@ -4,6 +4,7 @@ namespace App\Fluidbook;
 
 use App\Notifications\ToolboxNotification;
 use Cubist\Util\Files\Files;
+use Fluidbook\Tools\Jobs\ProcessFile;
 use hollodotme\FastCGI\Client;
 use hollodotme\FastCGI\Requests\PostRequest;
 use hollodotme\FastCGI\SocketConnections\NetworkSocket;
@@ -13,7 +14,9 @@ use Illuminate\Support\Facades\Log;
 class Farm
 {
 
-    protected static $_forceServer = 'alphaville';
+    protected static $_outPDF = [];
+    protected static $_forceServer = false;
+    //protected static $_forceServer = 'alphaville';
     protected static $_farmServers = [
         ['name' => 'alphaville', 'host' => 'fluidbook-processfarm', 'port' => 9000, 'weight' => 24, 'region' => 'UE'],
         ['name' => 'brazil', 'host' => 'brazil.cubedesigners.com', 'weight' => 2, 'region' => 'US'],
@@ -106,11 +109,19 @@ class Farm
         return self::_getFile($params);
     }
 
-    public static function getFileFromPDF($pdf, $page, $format, $resolution, $quality, $withText = true, $withGraphics = true, $version = 'html', $out = null, $force = false, $attemps = 3)
+    protected static function _getOutDirFromPDF($pdf)
     {
-        if (null === $out) {
+        if (!isset(self::$_outPDF[$pdf])) {
             $hash = Files::hashFileAttributes($pdf);
-            $out = Files::mkdir(protected_path('fluidbookpublication/cache/pdffiles/' . $hash));
+            self::$_outPDF[$pdf] = Files::mkdir(protected_path('fluidbookpublication/cache/pdffiles/' . $hash));
+        }
+        return self::$_outPDF[$pdf];
+    }
+
+    public static function getFileFromPDF($pdf, $page, $format, $resolution, $quality, $withText = true, $withGraphics = true, $version = 'html', $out = null, $force = false, $attempts = 3)
+    {
+        if (null === $out) {
+            $out = self::_getOutDirFromPDF($pdf);
         }
 
         $attrs = ['pdf' => $pdf,
@@ -133,12 +144,18 @@ class Farm
             Cache::forget($cachekey);
         }
 
-        $res = Cache::rememberForever($cachekey, function () use ($params) {
+        $res = Cache::rememberForever($cachekey, function () use ($params, $out) {
+            $path = $out . ProcessFile::getFilename($params['page'], $params['format'], $params['resolution'], $params['quality'], $params['withGraphics'], $params['withTexts'], $params['version']);
+            if (file_exists($path)) {
+                return $path;
+            }
             return self::_getFile($params);
         });
-        if ((!$res || !file_exists($res))) {
-            return self::getFileFromPDF($pdf, $page, $format, $resolution, $quality, $withText, $withGraphics, $version, $out, true, $attemps - 1);
+
+        if ((!$res || !file_exists($res)) && $attempts > 0) {
+            return self::getFileFromPDF($pdf, $page, $format, $resolution, $quality, $withText, $withGraphics, $version, $out, true, $attempts - 1);
         }
+
         return $res;
     }
 
index 8d17ba305f9a39af9b6114e4d8ba422a62ef5032..d7ea4a22c4cf1185b277a70e13ded6735290e7c6 100644 (file)
@@ -4,7 +4,7 @@ function LinkeditorRulers(linkeditor) {
     this.movingRuler = null;
     this.rulersMagnetValuesX = [];
     this.rulersMagnetValuesY = [];
-    this.dividers = [1, 2, 5, 10, 20, 50, 100, 200];
+    this.dividers = [1, 2, 5, 10, 20, 50, 100, 200, 500];
 
     this.init();
 }
@@ -69,12 +69,12 @@ LinkeditorRulers.prototype = {
         let visible_w = (this.linkeditor.canvasRect.width / this.linkeditor.fs) / this.linkeditor.zoom.zoom;
         let visible_h = (this.linkeditor.canvasRect.height / this.linkeditor.fs) / this.linkeditor.zoom.zoom;
 
-        // Find the best divider to have around 10 main divisions
+        // Find the best divider to have around 12 main divisions
         let divider = 0;
         for (let d in this.dividers) {
             divider = this.dividers[d];
             let v = visible_h / divider;
-            if (v <= 10) {
+            if (v <= 12) {
                 break;
             }
         }