From 982ddce087090cfc70d618ee5b0d86b745d45c75 Mon Sep 17 00:00:00 2001 From: Flummi Date: Tue, 29 Mar 2022 14:33:43 +0200 Subject: [PATCH] order by score @ tagsuggest --- public/s/js/admin.js | 4 ++-- src/inc/routes/apiv2/index.mjs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/public/s/js/admin.js b/public/s/js/admin.js index da36bc1..18afad3 100644 --- a/public/s/js/admin.js +++ b/public/s/js/admin.js @@ -177,7 +177,7 @@ const flash = ({ type, msg }) => { option.value = entry.tag; if(!/fox/.test(navigator.userAgent)) - option.innerText = `tagged ${entry.tagged} times`; + option.innerText = `tagged ${entry.tagged} times (score: ${entry.score.toFixed(2)})`; testList.insertAdjacentElement('beforeEnd', option); }; @@ -351,7 +351,7 @@ const flash = ({ type, msg }) => { if(document.location.pathname === '/settings') { const saveAvatar = async e => { e.preventDefault(); - + const avatar = +document.querySelector('input[name="i_avatar"]').value; let res = await fetch('/api/v2/settings/setAvatar', { method: 'PUT', diff --git a/src/inc/routes/apiv2/index.mjs b/src/inc/routes/apiv2/index.mjs index a7e1cd0..dee31f0 100644 --- a/src/inc/routes/apiv2/index.mjs +++ b/src/inc/routes/apiv2/index.mjs @@ -1,5 +1,6 @@ import sql from '../../sql.mjs'; import lib from '../../lib.mjs'; +import search from '../../routeinc/search.mjs'; const allowedMimes = [ "audio", "image", "video", "%" ]; export default router => { @@ -154,7 +155,7 @@ export default router => { .orderBy('tagged', 'desc') .limit(15); reply.success = true; - reply.suggestions = q; + reply.suggestions = search(q, searchString); } catch(err) { reply.error = err.msg; }