Commit 86cc740d authored by Phil Höfer's avatar Phil Höfer

Merge branch '262-metager-code-entzerren' into 'development'

combineResults teilsepariert

das eigentliche Kombinieren der Ergebnisse ist jetzt in einer eigenen Methode. Die restlichen Bestandteile müssen noch aufgeteilt werden.

See merge request !460
parents acd66ef3 901024f4
...@@ -28,7 +28,7 @@ class MetaGerSearch extends Controller ...@@ -28,7 +28,7 @@ class MetaGerSearch extends Controller
$metager->rankAll(); $metager->rankAll();
# Ergebnisse der Suchmaschinen kombinieren: # Ergebnisse der Suchmaschinen kombinieren:
$metager->combineResults(); $metager->prepareResults();
# Die Ausgabe erstellen: # Die Ausgabe erstellen:
return $metager->createView(); return $metager->createView();
......
...@@ -156,28 +156,18 @@ class MetaGer ...@@ -156,28 +156,18 @@ class MetaGer
} }
} }
public function combineResults() public function prepareResults()
{ {
foreach ($this->engines as $engine) { $engines = $this->engines;
if (isset($engine->next)) {
$this->next[] = $engine->next; // combine
} $combinedResults = $this->combineResults($engines);
if (isset($engine->last)) { // sort
$this->last[] = $engine->last; //$sortedResults = $this->sortResults($engines);
} // filter
foreach ($engine->results as $result) { // augment (boost&adgoal)
if ($result->valid) { // authorize
$this->results[] = $result; // misc (WiP)
}
}
foreach ($engine->ads as $ad) {
$this->ads[] = $ad;
}
foreach ($engine->products as $product) {
$this->products[] = $product;
}
}
uasort($this->results, function ($a, $b) { uasort($this->results, function ($a, $b) {
if ($a->getRank() == $b->getRank()) { if ($a->getRank() == $b->getRank()) {
return 0; return 0;
...@@ -275,6 +265,30 @@ class MetaGer ...@@ -275,6 +265,30 @@ class MetaGer
} }
public function combineResults($engines)
{
foreach ($engines as $engine) {
if (isset($engine->next)) {
$this->next[] = $engine->next;
}
if (isset($engine->last)) {
$this->last[] = $engine->last;
}
foreach ($engine->results as $result) {
if ($result->valid) {
$this->results[] = $result;
}
}
foreach ($engine->ads as $ad) {
$this->ads[] = $ad;
}
foreach ($engine->products as $product) {
$this->products[] = $product;
}
}
}
public function parseBoost($results) public function parseBoost($results)
{ {
foreach ($results as $result) { foreach ($results as $result) {
......
...@@ -233,7 +233,7 @@ class Result ...@@ -233,7 +233,7 @@ class Result
} }
} }
/* Der Dublettefilter, der sicher stellt, /* Der Dublettenfilter, der sicher stellt,
* dass wir nach Möglichkeit keinen Link doppelt in der Ergebnisliste haben. * dass wir nach Möglichkeit keinen Link doppelt in der Ergebnisliste haben.
*/ */
if ($metager->addLink($this->strippedLink)) { if ($metager->addLink($this->strippedLink)) {
......
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