mirror of https://github.com/kiwix/libkiwix.git
Reordered several statements
Reordered several statements so that the next couple of commits are a little simpler.
This commit is contained in:
parent
19b59fd72f
commit
208dece7e3
|
@ -666,8 +666,6 @@ InternalServer::search_catalog(const RequestContext& request,
|
||||||
{
|
{
|
||||||
auto filter = kiwix::Filter().valid(true).local(true);
|
auto filter = kiwix::Filter().valid(true).local(true);
|
||||||
string query("<Empty query>");
|
string query("<Empty query>");
|
||||||
size_t count(10);
|
|
||||||
size_t startIndex(0);
|
|
||||||
try {
|
try {
|
||||||
query = request.get_argument("q");
|
query = request.get_argument("q");
|
||||||
filter.query(query);
|
filter.query(query);
|
||||||
|
@ -684,12 +682,6 @@ InternalServer::search_catalog(const RequestContext& request,
|
||||||
try {
|
try {
|
||||||
filter.lang(request.get_argument("lang"));
|
filter.lang(request.get_argument("lang"));
|
||||||
} catch (const std::out_of_range&) {}
|
} catch (const std::out_of_range&) {}
|
||||||
try {
|
|
||||||
count = extractFromString<unsigned long>(request.get_argument("count"));
|
|
||||||
} catch (...) {}
|
|
||||||
try {
|
|
||||||
startIndex = extractFromString<unsigned long>(request.get_argument("start"));
|
|
||||||
} catch (...) {}
|
|
||||||
try {
|
try {
|
||||||
filter.acceptTags(kiwix::split(request.get_argument("tag"), ";"));
|
filter.acceptTags(kiwix::split(request.get_argument("tag"), ";"));
|
||||||
} catch (...) {}
|
} catch (...) {}
|
||||||
|
@ -699,6 +691,14 @@ InternalServer::search_catalog(const RequestContext& request,
|
||||||
opdsDumper.setTitle("Search result for " + query);
|
opdsDumper.setTitle("Search result for " + query);
|
||||||
std::vector<std::string> bookIdsToDump = mp_library->filter(filter);
|
std::vector<std::string> bookIdsToDump = mp_library->filter(filter);
|
||||||
const auto totalResults = bookIdsToDump.size();
|
const auto totalResults = bookIdsToDump.size();
|
||||||
|
size_t count(10);
|
||||||
|
size_t startIndex(0);
|
||||||
|
try {
|
||||||
|
count = extractFromString<unsigned long>(request.get_argument("count"));
|
||||||
|
} catch (...) {}
|
||||||
|
try {
|
||||||
|
startIndex = extractFromString<unsigned long>(request.get_argument("start"));
|
||||||
|
} catch (...) {}
|
||||||
const auto s = std::min(startIndex, totalResults);
|
const auto s = std::min(startIndex, totalResults);
|
||||||
bookIdsToDump.erase(bookIdsToDump.begin(), bookIdsToDump.begin()+s);
|
bookIdsToDump.erase(bookIdsToDump.begin(), bookIdsToDump.begin()+s);
|
||||||
if (count>0 && bookIdsToDump.size() > count) {
|
if (count>0 && bookIdsToDump.size() > count) {
|
||||||
|
|
Loading…
Reference in New Issue