From 1995cdaacf9866473dae48ae49bae7f638ec8f4e Mon Sep 17 00:00:00 2001 From: Flummi Date: Mon, 3 Jan 2022 05:14:43 +0100 Subject: [PATCH] show mode in favorites --- src/inc/routes/inc/f0cklib.mjs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/inc/routes/inc/f0cklib.mjs b/src/inc/routes/inc/f0cklib.mjs index 5679c1e..b998890 100644 --- a/src/inc/routes/inc/f0cklib.mjs +++ b/src/inc/routes/inc/f0cklib.mjs @@ -3,7 +3,6 @@ import lib from "../../lib.mjs"; import cfg from "../../config.mjs"; import fs from "fs"; import url from "url"; -import { ifError } from "assert"; export default { getf0cks: async (o = { user, tag, mime, page, mode, fav }) => { @@ -33,7 +32,7 @@ export default { sql("tags") .select("tags_assign.item_id", "tags.tag") .leftJoin("tags_assign", "tags_assign.tag_id", "tags.id") - .where("tags.tag", "like", "%"+tag+"%") + .where("tags.tag", "ilike", "%"+tag+"%") .groupBy("tags_assign.item_id", "tags.tag") .as("st"), "st.item_id", "items.id" @@ -93,16 +92,17 @@ export default { } else { rows = sql("favorites") - .select('items.id', 'items.mime') + .select('items.id', 'items.mime', 'ta.tag_id') .leftJoin('user', 'user.id', 'favorites.user_id') .leftJoin('tags_assign', 'tags_assign.item_id', 'favorites.item_id') .leftJoin('tags', 'tags.id', 'tags_assign.tag_id') .leftJoin('items', 'items.id', 'favorites.item_id') + .joinRaw("left join tags_assign as ta on ta.item_id = items.id and (ta.tag_id = 1 or ta.tag_id = 2)") .whereRaw(modequery) .andWhere('items.mime', 'ilike', smime) .andWhere('user.user', 'ilike', user) .orderBy('items.id', 'desc') - .groupBy('items.id') + .groupBy('items.id', 'ta.tag_id') .offset(offset) .limit(cfg.websrv.eps); } @@ -121,7 +121,9 @@ export default { .groupBy('st.item_id', 'items.id', 'tags_assign.tag_id'); } + rows = await rows; + if(rows.length === 0)