From 4cf3c6cb8a86b476bc7e781a3b07dd466e755405 Mon Sep 17 00:00:00 2001 From: Anas Rashid Date: Fri, 9 Oct 2026 14:56:32 +0200 Subject: [PATCH] E-books in the moderation queue and activity log: their title and link (were blank); rows say what kind of change they are Co-Authored-By: Claude Opus 5.5 --- api/src/moderation.ts | 7 ++++--- web/src/pages/mod/index.astro | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/api/src/moderation.ts b/api/src/moderation.ts index ef003bc9..b3b8a55d 100644 --- a/api/src/moderation.ts +++ b/api/src/moderation.ts @@ -84,7 +84,8 @@ async function current(poemId: number) { const TARGET = `LEFT JOIN poems p ON r.entity IN ('work', 'tags-work') AND p.id = r.entity_id LEFT JOIN categories c ON r.entity IN ('order', 'tags-category') AND c.id = r.entity_id LEFT JOIN ebooks b ON r.entity = 'ebook' AND b.id = r.entity_id`; -const TARGET_COLS = `coalesce(p.title, c.title, b.title) AS work_title, coalesce(p.url, c.url, '/ebook/' || b.id) AS work_url`; +const TITLE = `coalesce(p.title, c.title, b.title)`, URL = `coalesce(p.url, c.url, '/ebook/' || b.id)`; +const TARGET_COLS = `${TITLE} AS work_title, ${URL} AS work_url`; async function revision(id: number) { return (await pool.query(`SELECT r.*, ${TARGET_COLS} FROM revisions r ${TARGET} WHERE r.id = $1 AND r.entity IN ${ENTITIES}`, [id])).rows[0]; @@ -179,7 +180,7 @@ export function moderationRoutes(app: FastifyInstance) { const u = await moderator(req, reply); if (!u) return; const { rows } = await pool.query( `SELECT r.id, r.entity, r.entity_id, r.status, r.summary, r.author_id, r.author_email, r.reviewer_email, r.updated_at, - coalesce(p.title, c.title) AS title, coalesce(p.url, c.url) AS url + ${TITLE} AS title, ${URL} AS url FROM revisions r ${TARGET} WHERE r.entity IN ${ENTITIES} AND (r.status IN ('submitted', 'approved') OR (r.author_id = $1 AND r.status IN ('draft', 'returned') AND ${CHANGED})) ORDER BY r.updated_at DESC LIMIT 300`, [u.id]); @@ -360,7 +361,7 @@ export function moderationRoutes(app: FastifyInstance) { const u = await moderator(req, reply); if (!u) return; const page = Math.max(1, Number(req.query.page) || 1); const { rows } = await pool.query( - `SELECT e.at, e.actor_email, e.action, e.comment, r.id AS revision, r.entity, r.version, coalesce(p.title, c.title) AS title, coalesce(p.url, c.url) AS url + `SELECT e.at, e.actor_email, e.action, e.comment, r.id AS revision, r.entity, r.version, ${TITLE} AS title, ${URL} AS url FROM revision_events e JOIN revisions r ON r.id = e.revision_id ${TARGET} WHERE r.entity IN ${ENTITIES} AND ${CHANGED} ORDER BY e.at DESC, e.id DESC LIMIT 50 OFFSET ${(page - 1) * 50}`); diff --git a/web/src/pages/mod/index.astro b/web/src/pages/mod/index.astro index 11e23b67..4069bd82 100644 --- a/web/src/pages/mod/index.astro +++ b/web/src/pages/mod/index.astro @@ -12,6 +12,8 @@ if (!['mod-l2', 'mod-l1', 'admin'].includes(me.role)) return new Response('صر const token = Astro.cookies.get(COOKIE)!.value, showLog = Astro.url.searchParams.has('log'); const queue = showLog ? null : (await asUser(token, '/api/mod/queue')).data; const log = showLog ? (await asUser(token, '/api/mod/log')).data : null; +// what kind of change a row is (a work's text needs no label) +const KIND: Record = { order: 'ترتیب: ', 'tags-category': 'ٹیگ: ', 'tags-work': 'ٹیگ: ', ebook: 'ای بک: ' }; const groups = queue ? [ ['میرے مسودے', queue.mine, 'ابھی کوئی مسودہ نہیں۔ کسی کلام کے صفحے پر "ترمیم کریں" سے شروع کریں۔'], ...(me.role !== 'mod-l2' ? [['جائزے کے منتظر', queue.review, 'جائزے کے لیے کچھ نہیں۔']] : []), @@ -29,7 +31,7 @@ const groups = queue ? [
    {items.map((r) => (
  • - {r.title} + {KIND[r.entity] ?? ''}{r.title} {STATUS[r.status]}

    {r.summary || 'بغیر خلاصہ'} · {r.author_email} · {when(r.updated_at)}

  • @@ -47,7 +49,7 @@ const groups = queue ? [ {when(e.at)} {e.actor_email} {EVENT[e.action] ?? e.action}{e.version && e.action === 'published' ? ` (ورژن ${ud(e.version)})` : ''} - {e.title} + {KIND[e.entity] ?? ''}{e.title} {e.comment} ))} -- 2.47.3