diff --git a/html/logic.js b/html/logic.js index 21fb224..2980c37 100644 --- a/html/logic.js +++ b/html/logic.js @@ -306,7 +306,12 @@ async function getSearchResults(f) rssurl.searchParams.set("q", f.searchQuery); f.rssurl = rssurl.href; - f.message = `< ${Math.ceil(data["milliseconds"])} milliseconden`; + if (data["truncated"]) { + f.message = `De nieuwste ${f.foundDocs.length} resultaten worden getoond - probeer een specifiekere zoekvraag.`; + } else { + f.message = `${f.foundDocs.length} resultaten in < ${Math.ceil(data["milliseconds"])} milliseconden`; + } + f.busy=false; orderByDate(f, false); } diff --git a/partials/search.html b/partials/search.html index 64ae48b..48902d7 100644 --- a/partials/search.html +++ b/partials/search.html @@ -115,9 +115,9 @@ -
+ -
+ {% endblock %} diff --git a/sws.hh b/sws.hh index ca22f30..1272d6c 100644 --- a/sws.hh +++ b/sws.hh @@ -33,12 +33,12 @@ struct LockedSqw return packResultsJson(result); } - void addValue(const std::initializer_list>& values, const std::string& table="data") + void addValue(const std::initializer_list>& values, const std::string& table="data") { std::lock_guard l(sqwlock); sqw.addValue(values, table); } - void addValue(const std::vector>& values, const std::string& table="data") + void addValue(const std::vector>& values, const std::string& table="data") { std::lock_guard l(sqwlock); sqw.addValue(values, table); @@ -117,10 +117,10 @@ struct SimpleWebSystem { return sws.getIP(req); } - void log(const std::initializer_list>& fields) + void log(const std::initializer_list>& fields) { // add agent? - std::vector> values{{"user", user}, {"ip", getIP()}, {"tstamp", time(0)}}; + std::vector> values{{"user", user}, {"ip", getIP()}, {"tstamp", time(0)}}; for(const auto& f : fields) values.push_back(f); lsqw.addValue(values, "log"); diff --git a/tkserv.cc b/tkserv.cc index a9a899c..f3fc602 100644 --- a/tkserv.cc +++ b/tkserv.cc @@ -2238,6 +2238,7 @@ int main(int argc, char** argv) dt.start(); int mseclimit = 10000; + int itemlimit = 280; shared_ptr uc = s_uc; @@ -2258,7 +2259,14 @@ int main(int argc, char** argv) fmt::print("Categories: {}\n", categories); - auto sres = sh.search(term, categories, limit, mseclimit, 280); + auto sres = sh.search(term, categories, limit, mseclimit, itemlimit + 1); + bool truncated = false; + + if (sres.size() > itemlimit) { + sres.pop_back(); + truncated = true; + } + nlohmann::json results = nlohmann::json::array(); for(const auto& r : sres) { @@ -2283,13 +2291,16 @@ int main(int argc, char** argv) })); } + // soorten! auto usec = dt.lapUsec(); fmt::print("Got {} matches in {} msec\n", results.size(), usec/1000.0); g_stats.searchUsec += usec; nlohmann::json response=nlohmann::json::object(); + response["results"]= results; + response["truncated"] = truncated; response["milliseconds"] = usec/1000.0; res.set_content(response.dump(), "application/json");