Add date column to the built-in search engine

Adds a date column to the built-in search engine to show when a torrent was published/uploaded on the engine site.
When a plugin wants to show a date, it can now add a `pub_date` entry to its result dict. The value format is a unix timestamp (an integer representing seconds since epoch).
Plugins with no date support will keep working.

PR #20703.
This commit is contained in:
ducalex
2024-04-29 14:10:24 -04:00
committed by GitHub
parent 775b38079f
commit 42b87963fd
8 changed files with 40 additions and 10 deletions

View File

@@ -39,6 +39,7 @@
#include "base/global.h"
#include "base/logger.h"
#include "base/search/searchhandler.h"
#include "base/utils/datetime.h"
#include "base/utils/foreignapps.h"
#include "base/utils/random.h"
#include "base/utils/string.h"
@@ -301,6 +302,7 @@ int SearchController::generateSearchId() const
* - "nbLeechers"
* - "siteUrl"
* - "descrLink"
* - "pubDate"
*/
QJsonObject SearchController::getResults(const QList<SearchResult> &searchResults, const bool isSearchActive, const int totalResults) const
{
@@ -315,7 +317,8 @@ QJsonObject SearchController::getResults(const QList<SearchResult> &searchResult
{u"nbSeeders"_s, searchResult.nbSeeders},
{u"nbLeechers"_s, searchResult.nbLeechers},
{u"siteUrl"_s, searchResult.siteUrl},
{u"descrLink"_s, searchResult.descrLink}
{u"descrLink"_s, searchResult.descrLink},
{u"pubDate"_s, Utils::DateTime::toSecsSinceEpoch(searchResult.pubDate)}
};
}