From 45f32ad7311dd357ea738fc8ce936c731562b14d Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 1 Sep 2023 17:06:41 +0200 Subject: [PATCH] wip #6237 @1 --- app/Console/Kernel.php | 4 +-- app/Fluidbook/Farm.php | 31 +++++++++++++++----- resources/linkeditor/js/linkeditor.rulers.js | 6 ++-- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 13bc9d28f..1396ff70f 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -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(); } /** diff --git a/app/Fluidbook/Farm.php b/app/Fluidbook/Farm.php index c3c6926ec..40db9f626 100644 --- a/app/Fluidbook/Farm.php +++ b/app/Fluidbook/Farm.php @@ -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; } diff --git a/resources/linkeditor/js/linkeditor.rulers.js b/resources/linkeditor/js/linkeditor.rulers.js index 8d17ba305..d7ea4a22c 100644 --- a/resources/linkeditor/js/linkeditor.rulers.js +++ b/resources/linkeditor/js/linkeditor.rulers.js @@ -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; } } -- 2.39.5