Commit 965ca5d5 authored by Dominik Hebeler's avatar Dominik Hebeler

Waiting for a specified timeout if no main searchengines are defined

parent 568a3fb2
......@@ -706,8 +706,15 @@ class MetaGer
$timeStart = microtime(true);
$answered = [];
$results = null;
while (sizeof($enginesToWaitFor) > 0) {
$newEngine = $redis->blpop($this->redisResultWaitingKey, 5);
# If there is no main searchengine to wait for or if the only main engine is yahoo-ads we will define a timeout of 1s
$forceTimeout = null;
if (sizeof($enginesToWaitFor) === 0 || (sizeof($enginesToWaitFor) === 1 && $enginesToWaitFor[0]->name === "yahoo-ads")) {
$forceTimeout = 1;
}
while (sizeof($enginesToWaitFor) > 0 || ($forceTimeout !== null && (microtime(true) - $timeStart) < $forceTimeout)) {
$newEngine = $redis->blpop($this->redisResultWaitingKey, 1);
if ($newEngine === null || sizeof($newEngine) !== 2) {
continue;
} else {
......@@ -731,6 +738,13 @@ class MetaGer
$pipeline->hset($this->getRedisEngineResult() . "status", "startTime", $timeStart);
$pipeline->hset($this->getRedisEngineResult() . "status", "engineCount", sizeof($engines));
$pipeline->hset($this->getRedisEngineResult() . "status", "engineDelivered", sizeof($answered));
# Add the cached engines as answered
foreach ($engines as $engine) {
if ($engine->cached) {
$pipeline->hincrby($this->getRedisEngineResult() . "status", "engineDelivered", 1);
$pipeline->hincrby($this->getRedisEngineResult() . "status", "engineAnswered", 1);
}
}
foreach ($answered as $engine) {
$pipeline->hset($this->getRedisEngineResult() . $engine, "delivered", "1");
}
......
......@@ -103,7 +103,7 @@ function loadMoreResults() {
}
}
}
if ($(".no-results-error").length > 0 && $(".image-container > .image").length > 0) {
if ($(".no-results-error").length > 0 && ($(".image-container > .image").length > 0) || $(".result:not(.ad)").length > 0) {
$(".no-results-error").remove();
if ($(".alert.alert-danger > ul").children().length == 0) {
$(".alert.alert-danger").remove();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment