From 30c13a1cfbeb871083a0c35dd613339ce64a966b Mon Sep 17 00:00:00 2001 From: Flummi Date: Thu, 6 Jan 2022 04:09:00 +0100 Subject: [PATCH] issue #9 --- src/inc/routes/admin.mjs | 27 ++++++++++++++++++--------- views/admin/search.html | 2 +- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/inc/routes/admin.mjs b/src/inc/routes/admin.mjs index 5a98678..68f1178 100644 --- a/src/inc/routes/admin.mjs +++ b/src/inc/routes/admin.mjs @@ -97,15 +97,24 @@ export default (router, tpl) => { router.get(/^\/admin\/test(\/)?$/, auth, async (req, res) => { let ret; if(Object.keys(req.url.qs).length > 0) { - const tag = req.url.qs.tag; - - const rows = await sql("tags") - .select("items.id", "items.username", "tags.tag") - .leftJoin("tags_assign", "tags_assign.tag_id", "tags.id") - .leftJoin("items", "items.id", "tags_assign.item_id") - .where("tags.tag", "like", '%'+tag+'%'); - - ret = search(rows, tag); + let tag = req.url.qs.tag; + let rows; + + if(tag.startsWith('src:')) { + tag = tag.substring(4); + ret = await sql('items') + .where('src', 'ilike', '%'+tag+'%') + .limit(500); + } + else { + rows = await sql("tags") + .select("items.id", "items.username", "tags.tag") + .leftJoin("tags_assign", "tags_assign.tag_id", "tags.id") + .leftJoin("items", "items.id", "tags_assign.item_id") + .where("tags.tag", "like", '%'+tag+'%') + .limit(500); + ret = search(rows, tag); + } } res.reply({ diff --git a/views/admin/search.html b/views/admin/search.html index 956453b..4545972 100644 --- a/views/admin/search.html +++ b/views/admin/search.html @@ -17,7 +17,7 @@ {{ line.id }} - {{ line.tag }} + {{ line.tag }} {{ line.username }} {{ line.score }}