DistroqueryAPI: getRepositoryPackages: better sort results by query relevance
This commit is contained in:
parent
fd5a9768da
commit
f90a4edb6b
@ -116,8 +116,17 @@ json DistroqueryAPI::getRepositoryPackages(string repository, int per_page, int
|
||||
archorder++;
|
||||
}
|
||||
|
||||
sql += ") AS u ORDER BY name COLLATE NOCASE ASC,sort"
|
||||
" LIMIT " + to_string(per_page) +
|
||||
sql += ") AS u";
|
||||
|
||||
if (query != "") {
|
||||
sql += " ORDER BY name='" + query + "' COLLATE NOCASE DESC, "
|
||||
"name LIKE '" + query + "%' DESC,"
|
||||
"summary LIKE '%" + query + "%' DESC,"
|
||||
" name COLLATE NOCASE ASC,sort";
|
||||
} else {
|
||||
sql += " ORDER BY name COLLATE NOCASE ASC,sort";
|
||||
}
|
||||
sql += " LIMIT " + to_string(per_page) +
|
||||
" OFFSET " + to_string(per_page * (page -1));
|
||||
|
||||
if (sqlite3_prepare_v2(db, sql.c_str(), sql.length(), &stmt, NULL) == SQLITE_OK) {
|
||||
|
Loading…
Reference in New Issue
Block a user