Commit 2cab70c7 authored by Dominik Hebeler's avatar Dominik Hebeler

Fixed resultloader

parent 03e5fe7a
...@@ -63,7 +63,15 @@ class MetaGerSearch extends Controller ...@@ -63,7 +63,15 @@ class MetaGerSearch extends Controller
# Ergebnisse der Suchmaschinen kombinieren: # Ergebnisse der Suchmaschinen kombinieren:
$metager->prepareResults(); $metager->prepareResults();
\App\CacheHelper::put($metager->getSearchUid(), $metager->getEngines(), 1 * 60); $finished = true;
foreach ($metager->getEngines() as $engine) {
if ($engine->loaded) {
$engine->setNew(false);
$engine->markNew();
}
}
\App\CacheHelper::put("loader_" . $metager->getSearchUid(), $metager->getEngines(), 60 * 60);
# Die Ausgabe erstellen: # Die Ausgabe erstellen:
$resultpage = $metager->createView($quicktipResults); $resultpage = $metager->createView($quicktipResults);
...@@ -112,18 +120,7 @@ class MetaGerSearch extends Controller ...@@ -112,18 +120,7 @@ class MetaGerSearch extends Controller
return response()->json(['finished' => true]); return response()->json(['finished' => true]);
} }
// Mark all engines that are already loaded $metager = new MetaGer(substr($hash, strpos($hash, "loader_") + 7));
$finished = true;
foreach ($engines as $engine) {
if ($engine->loaded) {
$engine->setNew(false);
} else {
$finished = false;
$engine->setNew(true);
}
}
$metager = new MetaGer($hash);
$metager->parseFormData($request); $metager->parseFormData($request);
# Nach Spezialsuchen überprüfen: # Nach Spezialsuchen überprüfen:
...@@ -156,8 +153,20 @@ class MetaGerSearch extends Controller ...@@ -156,8 +153,20 @@ class MetaGerSearch extends Controller
} }
} }
$finished = true;
foreach ($engines as $engine) {
if (!$engine->loaded) {
$finished = false;
} else {
$engine->setNew(false);
$engine->markNew();
}
}
$result["finished"] = $finished;
// Update new Engines // Update new Engines
\App\CacheHelper::put($metager->getSearchUid(), $metager->getEngines(), 1 * 60); \App\CacheHelper::put("loader_" . $metager->getSearchUid(), $metager->getEngines(), 1 * 60);
return response()->json($result); return response()->json($result);
} }
......
...@@ -71,6 +71,7 @@ class MetaGer ...@@ -71,6 +71,7 @@ class MetaGer
protected $verificationCount; protected $verificationCount;
protected $searchUid; protected $searchUid;
protected $redisResultWaitingKey, $redisResultEngineList, $redisEngineResult, $redisCurrentResultList; protected $redisResultWaitingKey, $redisResultEngineList, $redisEngineResult, $redisCurrentResultList;
public $starttime;
public function __construct($hash = "") public function __construct($hash = "")
{ {
......
...@@ -51,7 +51,7 @@ abstract class Searchengine ...@@ -51,7 +51,7 @@ abstract class Searchengine
$this->useragent = $metager->getUserAgent(); $this->useragent = $metager->getUserAgent();
$this->ip = $metager->getIp(); $this->ip = $metager->getIp();
$this->startTime = microtime(); $this->startTime = microtime(true);
# check for http Auth # check for http Auth
if (!empty($this->engine->{"http-auth-credentials"}->username) && !empty($this->engine->{"http-auth-credentials"}->password)) { if (!empty($this->engine->{"http-auth-credentials"}->username) && !empty($this->engine->{"http-auth-credentials"}->password)) {
$this->username = $this->engine->{"http-auth-credentials"}->username; $this->username = $this->engine->{"http-auth-credentials"}->username;
...@@ -192,7 +192,7 @@ abstract class Searchengine ...@@ -192,7 +192,7 @@ abstract class Searchengine
} }
} }
protected function markNew() public function markNew()
{ {
foreach ($this->results as $result) { foreach ($this->results as $result) {
$result->new = $this->new; $result->new = $this->new;
......
...@@ -55,7 +55,7 @@ function enableFormResetter() { ...@@ -55,7 +55,7 @@ function enableFormResetter() {
function loadMoreResults() { function loadMoreResults() {
var searchKey = $("meta[name=searchkey]").attr("content"); var searchKey = $("meta[name=searchkey]").attr("content");
var updateUrl = document.location.href; var updateUrl = document.location.href;
updateUrl += "&loadMore=" + searchKey + "&script=yes"; updateUrl += "&loadMore=loader_" + searchKey + "&script=yes";
updateUrl = updateUrl.replace("/meta.ger3", "/loadMore"); updateUrl = updateUrl.replace("/meta.ger3", "/loadMore");
......
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