This commit is contained in:
Flummi 2022-01-06 04:09:00 +01:00
parent 90a86133db
commit 30c13a1cfb
2 changed files with 19 additions and 10 deletions

View File

@ -97,16 +97,25 @@ export default (router, tpl) => {
router.get(/^\/admin\/test(\/)?$/, auth, async (req, res) => { router.get(/^\/admin\/test(\/)?$/, auth, async (req, res) => {
let ret; let ret;
if(Object.keys(req.url.qs).length > 0) { if(Object.keys(req.url.qs).length > 0) {
const tag = req.url.qs.tag; let tag = req.url.qs.tag;
let rows;
const rows = await sql("tags") 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") .select("items.id", "items.username", "tags.tag")
.leftJoin("tags_assign", "tags_assign.tag_id", "tags.id") .leftJoin("tags_assign", "tags_assign.tag_id", "tags.id")
.leftJoin("items", "items.id", "tags_assign.item_id") .leftJoin("items", "items.id", "tags_assign.item_id")
.where("tags.tag", "like", '%'+tag+'%'); .where("tags.tag", "like", '%'+tag+'%')
.limit(500);
ret = search(rows, tag); ret = search(rows, tag);
} }
}
res.reply({ res.reply({
body: tpl.render("admin/search", { body: tpl.render("admin/search", {

View File

@ -17,7 +17,7 @@
<tr> <tr>
<td style="width: 128px;"><a href="/{{ line.id }}" target="_blank"><img src="/t/{{ line.id }}.webp" /></a></td> <td style="width: 128px;"><a href="/{{ line.id }}" target="_blank"><img src="/t/{{ line.id }}.webp" /></a></td>
<td style="text-align: center;"><a href="/{{ line.id }}" target="_blank">{{ line.id }}</a></td> <td style="text-align: center;"><a href="/{{ line.id }}" target="_blank">{{ line.id }}</a></td>
<td style="text-align: center;"><a href="/admin/test?tag={{ line.tag.replace(/\s/g, "+") }}">{{ line.tag }}</a></td> <td style="text-align: center;"><a href="/admin/test?tag={{ line.tag?.replace(/\s/g, "+") }}">{{ line.tag }}</a></td>
<td style="text-align: center;">{{ line.username }}</td> <td style="text-align: center;">{{ line.username }}</td>
<td style="text-align: center;">{{ line.score }}</td> <td style="text-align: center;">{{ line.score }}</td>
</tr> </tr>