search: default sort by mtime and page
Αυτή η υποβολή περιλαμβάνεται σε:
γονέας
8c027566e3
υποβολή
c338bb20bd
@ -194,8 +194,8 @@ QPair<QString, QVector<QString>> SqliteSearch::createSql(const SqliteSearch::Tok
|
|||||||
QSqlQuery SqliteSearch::makeSqlQuery(const QVector<SqliteSearch::Token> &tokens)
|
QSqlQuery SqliteSearch::makeSqlQuery(const QVector<SqliteSearch::Token> &tokens)
|
||||||
{
|
{
|
||||||
QString whereSql;
|
QString whereSql;
|
||||||
QString sortSql;
|
|
||||||
QString limitSql;
|
QString limitSql;
|
||||||
|
QString sortSql;
|
||||||
QVector<QString> bindValues;
|
QVector<QString> bindValues;
|
||||||
bool isContentSearch = false;
|
bool isContentSearch = false;
|
||||||
for(const Token &c : tokens)
|
for(const Token &c : tokens)
|
||||||
@ -223,6 +223,10 @@ QSqlQuery SqliteSearch::makeSqlQuery(const QVector<SqliteSearch::Token> &tokens)
|
|||||||
QString prepSql;
|
QString prepSql;
|
||||||
if(isContentSearch)
|
if(isContentSearch)
|
||||||
{
|
{
|
||||||
|
if(sortSql.isEmpty())
|
||||||
|
{
|
||||||
|
sortSql = "ORDER BY file.mtime DESC, content.page ASC";
|
||||||
|
}
|
||||||
prepSql =
|
prepSql =
|
||||||
"SELECT file.path AS path, group_concat(content.page) AS pages, file.mtime AS mtime, file.size AS size, "
|
"SELECT file.path AS path, group_concat(content.page) AS pages, file.mtime AS mtime, file.size AS size, "
|
||||||
"file.filetype AS filetype FROM file INNER JOIN content ON file.id = content.fileid WHERE 1=1 AND " +
|
"file.filetype AS filetype FROM file INNER JOIN content ON file.id = content.fileid WHERE 1=1 AND " +
|
||||||
@ -230,6 +234,10 @@ QSqlQuery SqliteSearch::makeSqlQuery(const QVector<SqliteSearch::Token> &tokens)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if(sortSql.isEmpty())
|
||||||
|
{
|
||||||
|
sortSql = "ORDER BY file.mtime DESC";
|
||||||
|
}
|
||||||
prepSql = "SELECT file.path AS path, '0' as pages, file.mtime AS mtime, file.size AS size, file.filetype AS "
|
prepSql = "SELECT file.path AS path, '0' as pages, file.mtime AS mtime, file.size AS size, file.filetype AS "
|
||||||
"filetype FROM file WHERE 1=1 AND " +
|
"filetype FROM file WHERE 1=1 AND " +
|
||||||
whereSql + " " + sortSql;
|
whereSql + " " + sortSql;
|
||||||
|
Φόρτωση…
Αναφορά σε νέο ζήτημα
Block a user