fix: undefined query showing in searches

isekai-main
Barış Soner Uşaklı 3 years ago
parent 89f5e06bbf
commit 6cfaea06f0

@ -99,9 +99,11 @@ searchController.search = async function (req, res, next) {
async function recordSearch(data) {
const { query, searchIn } = data;
const cleanedQuery = String(query).trim().toLowerCase().substr(0, 255);
if (['titles', 'titlesposts', 'posts'].includes(searchIn) && cleanedQuery.length > 2) {
await db.sortedSetIncrBy('searches:all', 1, cleanedQuery);
if (query) {
const cleanedQuery = String(query).trim().toLowerCase().substr(0, 255);
if (['titles', 'titlesposts', 'posts'].includes(searchIn) && cleanedQuery.length > 2) {
await db.sortedSetIncrBy('searches:all', 1, cleanedQuery);
}
}
}

Loading…
Cancel
Save