]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5996 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 7 Jun 2023 17:03:06 +0000 (19:03 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 7 Jun 2023 17:03:06 +0000 (19:03 +0200)
.env.dev
app/Fluidbook/Link/LinksData.php

index c9556124763fc4d12df1c9ab849ef90e656fc1ba..088dccccbefa4c707ebb87365443765a5b40ae39 100644 (file)
--- a/.env.dev
+++ b/.env.dev
@@ -2,7 +2,7 @@ APP_NAME="[DEV] Fluidbook Toolbox"
 APP_ENV=development
 APP_KEY=base64:DRIdIwSEuQNkxuUTfyyRyssizosh3D9QHWTnobrW44U=
 APP_DEBUG=true
-DEBUGBAR_ENABLED=false
+DEBUGBAR_ENABLED=true
 
 APP_URL=https://dev.toolbox.fluidbook.com
 HEADER_COLOR="#df4759"
index 95ce5c1e0cf639181c5f632c78ee3a0c07e21b1c..7f5f8b91a1d495c548abb3795e4afd9017dcac84 100644 (file)
@@ -21,6 +21,8 @@ class LinksData
     protected static $_testLinkCache = null;
     protected static $_linksKey = null;
 
+    protected static $_names = [];
+
     protected static $_webvideoServicesMap = [0 => 'youtube', 1 => 'dailymotion', 2 => 'vimeo', 3 => 'brightcove', 'none' => 'youtube'];
 
     /**
@@ -485,11 +487,7 @@ class LinksData
 
         $res = [];
         foreach ($updates as $timestamp => $u) {
-            try {
-                $u['name'] = User::find($u['user'])->name;
-            } catch (\Exception $e) {
-                $u['name'] = '-';
-            }
+            $u['name'] = self::getName($u['user']);
             $u['date'] = date('Y-m-d H:i:s', $timestamp);
             $u['timestamp'] = $timestamp;
             $res[] = $u;
@@ -498,6 +496,18 @@ class LinksData
         return $res;
     }
 
+    protected static function getName($u)
+    {
+        if (!isset(self::$_names[$u])) {
+            try {
+                self::$_names[$u] = User::find($u)->name;
+            } catch (\Exception $e) {
+                self::$_names[$u] = '-';
+            }
+        }
+        return self::$_names[$u];
+    }
+
     public static function getMeta($book_id, $update = 'latest')
     {
         return json_decode(gzdecode(file_get_contents(Files::firstThatExists(self::getLinksDir($book_id) . '/' . $update . '.meta3.gz', self::getLinksDir($book_id) . '/' . $update . '.meta.gz'))), true);