From 46b7b4bc958426cee8bd259134c0f4dc385e0fcc Mon Sep 17 00:00:00 2001 From: Dominik Hebeler <dominik@suma-ev.de> Date: Mon, 26 Oct 2020 14:56:49 +0100 Subject: [PATCH] quicktip timer now starts when search is started --- app/Models/Quicktips/Quicktips.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Models/Quicktips/Quicktips.php b/app/Models/Quicktips/Quicktips.php index 976e3d4cc..152268e7b 100644 --- a/app/Models/Quicktips/Quicktips.php +++ b/app/Models/Quicktips/Quicktips.php @@ -16,6 +16,7 @@ class Quicktips const CACHE_DURATION = 60; private $hash; + private $startTime; public function __construct($search, $locale, $max_time) { @@ -24,6 +25,7 @@ class Quicktips } else { $this->quicktipUrl = "https://dev.quicktips.metager.de" . $this->quicktipUrl; } + $this->startTime = microtime(true); $this->startSearch($search, $locale, $max_time); } @@ -75,20 +77,18 @@ class Quicktips { $body = null; - $startTime = microtime(true); - if (Cache::has($this->hash)) { return Cache::get($this->hash, false); } - while (microtime(true) - $startTime < 0.5) { + do { $body = Redis::rpoplpush($this->hash, $this->hash); if ($body === false || $body === null) { usleep(50 * 1000); } else { break; } - } + } while (microtime(true) - $this->startTime < 0.5); if ($body === false) { return false; -- GitLab