Added search time to searchr results page
This commit is contained in:
parent
6c4c00b156
commit
84f6005db0
|
@ -2174,8 +2174,9 @@ register_module([
|
|||
|
||||
$invindex = search::load_invindex($paths->searchindex);
|
||||
$results = search::query_invindex($_GET["query"], $invindex);
|
||||
$resultCount = count($results);
|
||||
|
||||
$search_end = microtime(true) - $search_start;
|
||||
$env->perfdata->search_time = round((microtime(true) - $search_start)*1000, 3);
|
||||
|
||||
$title = $_GET["query"] . " - Search results - $settings->sitename";
|
||||
|
||||
|
@ -2188,14 +2189,16 @@ register_module([
|
|||
$content .= " <input type='hidden' name='action' value='search' />\n";
|
||||
$content .= "</form>";
|
||||
|
||||
$content .= "<p>Found $resultCount " . ($resultCount === 1 ? "result" : "results") . " in " . $env->perfdata->search_time . "ms. ";
|
||||
|
||||
$query = $_GET["query"];
|
||||
if(isset($pageindex->$query))
|
||||
{
|
||||
$content .= "<p>There's a page on $settings->sitename called <a href='?page=" . rawurlencode($query) . "'>$query</a>.</p>";
|
||||
$content .= "There's a page on $settings->sitename called <a href='?page=" . rawurlencode($query) . "'>$query</a>.";
|
||||
}
|
||||
else
|
||||
{
|
||||
$content .= "<p>There isn't a page called $query on $settings->sitename, but you ";
|
||||
$content .= "There isn't a page called $query on $settings->sitename, but you ";
|
||||
if((!$settings->anonedits && !$env->is_logged_in) || !$settings->editing)
|
||||
{
|
||||
$content .= "do not have permission to create it.";
|
||||
|
@ -2206,9 +2209,10 @@ register_module([
|
|||
}
|
||||
else
|
||||
{
|
||||
$content .= "can <a href='?action=edit&page=" . rawurlencode($query) . "'>create it</a>.</p>";
|
||||
$content .= "can <a href='?action=edit&page=" . rawurlencode($query) . "'>create it</a>.";
|
||||
}
|
||||
}
|
||||
$content .= "</p>";
|
||||
|
||||
$i = 0; // todo use $_GET["offset"] and $_GET["result-count"] or something
|
||||
foreach($results as $result)
|
|
@ -68,7 +68,7 @@
|
|||
"author": "Starbeamrainbowlabs",
|
||||
"description": "Adds proper search functionality to Pepperminty Wiki using an inverted index to provide a full text search engine. If pages don't show up, then you might have hit a stop word. If not, try requesting the `invindex-rebuild` action to rebuild the inverted index from scratch.",
|
||||
"id": "feature-search",
|
||||
"lastupdate": 1471688611,
|
||||
"lastupdate": 1471689193,
|
||||
"optional": false
|
||||
},
|
||||
{
|
|
@ -95,8 +95,9 @@ register_module([
|
|||
|
||||
$invindex = search::load_invindex($paths->searchindex);
|
||||
$results = search::query_invindex($_GET["query"], $invindex);
|
||||
$resultCount = count($results);
|
||||
|
||||
$search_end = microtime(true) - $search_start;
|
||||
$env->perfdata->search_time = round((microtime(true) - $search_start)*1000, 3);
|
||||
|
||||
$title = $_GET["query"] . " - Search results - $settings->sitename";
|
||||
|
||||
|
@ -109,14 +110,16 @@ register_module([
|
|||
$content .= " <input type='hidden' name='action' value='search' />\n";
|
||||
$content .= "</form>";
|
||||
|
||||
$content .= "<p>Found $resultCount " . ($resultCount === 1 ? "result" : "results") . " in " . $env->perfdata->search_time . "ms. ";
|
||||
|
||||
$query = $_GET["query"];
|
||||
if(isset($pageindex->$query))
|
||||
{
|
||||
$content .= "<p>There's a page on $settings->sitename called <a href='?page=" . rawurlencode($query) . "'>$query</a>.</p>";
|
||||
$content .= "There's a page on $settings->sitename called <a href='?page=" . rawurlencode($query) . "'>$query</a>.";
|
||||
}
|
||||
else
|
||||
{
|
||||
$content .= "<p>There isn't a page called $query on $settings->sitename, but you ";
|
||||
$content .= "There isn't a page called $query on $settings->sitename, but you ";
|
||||
if((!$settings->anonedits && !$env->is_logged_in) || !$settings->editing)
|
||||
{
|
||||
$content .= "do not have permission to create it.";
|
||||
|
@ -127,9 +130,10 @@ register_module([
|
|||
}
|
||||
else
|
||||
{
|
||||
$content .= "can <a href='?action=edit&page=" . rawurlencode($query) . "'>create it</a>.</p>";
|
||||
$content .= "can <a href='?action=edit&page=" . rawurlencode($query) . "'>create it</a>.";
|
||||
}
|
||||
}
|
||||
$content .= "</p>";
|
||||
|
||||
$i = 0; // todo use $_GET["offset"] and $_GET["result-count"] or something
|
||||
foreach($results as $result)
|
Loading…
Reference in New Issue