sort autocomplete by score + show score

This commit is contained in:
Daku 2016-06-18 13:18:59 +01:00
parent 4bd9ee1c7f
commit 2546621c59
2 changed files with 10 additions and 4 deletions

View File

@ -20,8 +20,14 @@ class AutoComplete extends Extension {
$SQLarr['limit'] = $_GET["limit"]; $SQLarr['limit'] = $_GET["limit"];
} }
$res = $database->get_col( $res = $database->get_pairs("
"SELECT tag FROM tags WHERE tag LIKE :search AND count > 0 $limitSQL", $SQLarr); SELECT tag, count
FROM tags
WHERE tag LIKE :search
AND count > 0
ORDER BY count DESC
$limitSQL", $SQLarr
);
$page->set_mode("data"); $page->set_mode("data");
$page->set_type("application/json"); $page->set_type("application/json");

View File

@ -18,10 +18,10 @@ $(function(){
dataType : 'json', dataType : 'json',
type : 'GET', type : 'GET',
success : function (data) { success : function (data) {
response($.map(data, function (item) { response($.map(data, function (count, item) {
item = (isNegative ? '-'+item : item); item = (isNegative ? '-'+item : item);
return { return {
label : item, label : item + ' ('+count+')',
value : item value : item
} }
})); }));