Handler: queryOption: Take default sort order param. History: default descending

This commit is contained in:
Albert S. 2020-12-31 16:15:36 +01:00
parent b9ff4068bd
commit 0c66fdf70d
3 changed files with 13 additions and 6 deletions

View File

@ -50,7 +50,7 @@ std::string Handler::createPageTitle(std::string title)
return replacer.parse(this->handlersConfig->page_title_template);
}
QueryOption Handler::queryOption(const Request &r) const
QueryOption Handler::queryOption(const Request &r, SORT_ORDER defaultSort) const
{
QueryOption result;
result.includeInvisible = false;
@ -71,10 +71,17 @@ QueryOption Handler::queryOption(const Request &r) const
result.offset = 0;
}
std::string order = r.get("sort");
result.order = ASCENDING;
if(order == "1")
result.order = defaultSort;
if(order != "")
{
result.order = DESCENDING;
if(order == "1")
{
result.order = DESCENDING;
}
else
{
result.order = ASCENDING;
}
}
return result;

View File

@ -21,7 +21,7 @@ class Handler
// TODO: may not to find a better place for this method
Permissions effectivePermissions(std::string page);
QueryOption queryOption(const Request &r) const;
QueryOption queryOption(const Request &r, SORT_ORDER defaultSort = ASCENDING) const;
public:
Handler(HandlerConfig &handlersConfig, Template &templ, Database &db, Session &userSession, UrlProvider &provider,

View File

@ -25,7 +25,7 @@ SOFTWARE.
#include "../database/exceptions.h"
Response HandlerHistory::handleRequest(const Request &r)
{
QueryOption qo = queryOption(r);
QueryOption qo = queryOption(r, DESCENDING);
std::string page = r.get("page");
std::string title;
if(page.empty())