Merge pull request #305 from kiwix/notag-parameter

add notag parameter to the api
This commit is contained in:
Matthieu Gautier 2019-07-29 14:51:31 +02:00 committed by GitHub
commit 79a64d5af3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -698,6 +698,7 @@ static struct MHD_Response* handle_catalog(RequestContext* request)
std::string query; std::string query;
std::string language; std::string language;
std::vector<std::string> tags; std::vector<std::string> tags;
std::vector<std::string> noTags;
size_t count(10); size_t count(10);
size_t startIndex(0); size_t startIndex(0);
try { try {
@ -715,13 +716,18 @@ static struct MHD_Response* handle_catalog(RequestContext* request)
try { try {
tags.push_back(request->get_argument("tag")); tags.push_back(request->get_argument("tag"));
} catch (...) {} } catch (...) {}
try {
noTags = kiwix::split(request->get_argument("notag"), ";");
} catch (...) {}
opdsDumper.setTitle("Search result for " + query); opdsDumper.setTitle("Search result for " + query);
uuid = zim::Uuid::generate(); uuid = zim::Uuid::generate();
bookIdsToDump = library.filter( bookIdsToDump = library.filter(
kiwix::Filter().valid(true).local(true).remote(true) kiwix::Filter().valid(true).local(true).remote(true)
.query(query) .query(query)
.lang(language) .lang(language)
.acceptTags(tags)); .acceptTags(tags)
.rejectTags(noTags)
);
auto totalResults = bookIdsToDump.size(); auto totalResults = bookIdsToDump.size();
bookIdsToDump.erase(bookIdsToDump.begin(), bookIdsToDump.begin()+startIndex); bookIdsToDump.erase(bookIdsToDump.begin(), bookIdsToDump.begin()+startIndex);
if (count>0 && bookIdsToDump.size() > count) { if (count>0 && bookIdsToDump.size() > count) {