]> _ Git - tortuga-home.git/commitdiff
.
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 26 Oct 2022 14:34:27 +0000 (16:34 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 26 Oct 2022 14:34:27 +0000 (16:34 +0200)
.idea/workspace.xml
scripts/lib/ical.php
scripts/lib/redis.php
scripts/lib/switchbot.php

index 8efa6645a6d70d5a3967678cf1d5d875affe00bc..2534e7805a006ded1866bdeebd4f12727ebaf9b5 100644 (file)
@@ -3,8 +3,8 @@
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/scripts/hotwater.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/hotwater.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/scripts/lib/ical.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/ical.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/redis.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/redis.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/scripts/lib/switchbot.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/switchbot.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
       <workItem from="1665644884295" duration="20000" />
       <workItem from="1665655356996" duration="39000" />
       <workItem from="1665922708761" duration="719000" />
-      <workItem from="1666248330245" duration="384000" />
-    </task>
-    <task id="LOCAL-00485" summary=".">
-      <created>1621493667425</created>
-      <option name="number" value="00485" />
-      <option name="presentableId" value="LOCAL-00485" />
-      <option name="project" value="LOCAL" />
-      <updated>1621493667425</updated>
+      <workItem from="1666248330245" duration="464000" />
+      <workItem from="1666784917537" duration="1072000" />
     </task>
     <task id="LOCAL-00486" summary=".">
       <created>1621494387501</created>
       <option name="project" value="LOCAL" />
       <updated>1665953404594</updated>
     </task>
-    <option name="localTasksCounter" value="534" />
+    <task id="LOCAL-00534" summary=".">
+      <created>1666248746111</created>
+      <option name="number" value="00534" />
+      <option name="presentableId" value="LOCAL-00534" />
+      <option name="project" value="LOCAL" />
+      <updated>1666248746111</updated>
+    </task>
+    <option name="localTasksCounter" value="535" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
index aa02e9b0fbc0a6c6d092a1ebcdcf1ac887df0c3a..3adf328d8b99e18ce42eb5a9c0b0ff3952c8127d 100644 (file)
@@ -30,7 +30,6 @@ function searchIcalEvent($cal, $start = null, $end = null)
 
     $client = icalClient();
     $client->SetCalendar($calendarBase . '/' . trim($cal, '/') . '/');
-
     $events = $client->GetEvents(getIcalTimestamp($start), getIcalTimestamp($end));
     $res = [];
     foreach ($events as $event) {
index bb0406fd7fe590afc0b63bdf391fed157127e163..f56cb2b8340aa2010492e0fee0334c245f98c7db 100644 (file)
@@ -112,15 +112,21 @@ function redisEventListener($channel, $callback)
  * @param $closure Closure
  * @return mixed
  */
-function remember($key, $ttl, $closure)
+function remember($key, $ttl, $closure, $default = null)
 {
+    $rememberSaveKey = $key . '_save_remember';
     $client = getRedisClient();
     if (!$client->exists($key)) {
-        $data = call_user_func($closure);
+        try {
+            $data = call_user_func($closure);
+        } catch (Exception $e) {
+            $data = getState($rememberSaveKey, $default);
+        }
         $client->set($key, $data);
         $client->expire($key, $ttl);
     } else {
         $data = $client->get($key);
     }
+    setState($rememberSaveKey, $data);
     return $data;
 }
index 16ad5730bf6348ab4a8d96830a59830fecd12488..2a4ddc4a4e23951ed0ef5a0e43398281a3b98dc5 100644 (file)
@@ -98,7 +98,7 @@ function isVincent()
 {
     return remember('vincent_in_paris', 3600, function () {
         return _isVincent();
-    });
+    }, true);
 }
 
 function _isVincent()
@@ -117,7 +117,7 @@ function isJerome()
 {
     return remember('jerome_in_paris', 3600, function () {
         return _isJerome();
-    });
+    }, true);
 }
 
 function _isJerome()