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 <noreply@anthropic.com>
This commit is contained in:
Anas Rashid 2026-10-09 14:56:32 +02:00
parent 09336ead0e
commit 526312aa8e
2 changed files with 8 additions and 5 deletions

View File

@ -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 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 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`; 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) { 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]; 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 u = await moderator(req, reply); if (!u) return;
const { rows } = await pool.query( 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, `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} 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})) 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]); 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 u = await moderator(req, reply); if (!u) return;
const page = Math.max(1, Number(req.query.page) || 1); const page = Math.max(1, Number(req.query.page) || 1);
const { rows } = await pool.query( 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} FROM revision_events e JOIN revisions r ON r.id = e.revision_id ${TARGET}
WHERE r.entity IN ${ENTITIES} AND ${CHANGED} WHERE r.entity IN ${ENTITIES} AND ${CHANGED}
ORDER BY e.at DESC, e.id DESC LIMIT 50 OFFSET ${(page - 1) * 50}`); ORDER BY e.at DESC, e.id DESC LIMIT 50 OFFSET ${(page - 1) * 50}`);

View File

@ -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 token = Astro.cookies.get(COOKIE)!.value, showLog = Astro.url.searchParams.has('log');
const queue = showLog ? null : (await asUser(token, '/api/mod/queue')).data; const queue = showLog ? null : (await asUser(token, '/api/mod/queue')).data;
const log = showLog ? (await asUser(token, '/api/mod/log')).data : null; 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<string, string> = { order: 'ترتیب: ', 'tags-category': 'ٹیگ: ', 'tags-work': 'ٹیگ: ', ebook: 'ای بک: ' };
const groups = queue ? [ const groups = queue ? [
['میرے مسودے', queue.mine, 'ابھی کوئی مسودہ نہیں۔ کسی کلام کے صفحے پر "ترمیم کریں" سے شروع کریں۔'], ['میرے مسودے', queue.mine, 'ابھی کوئی مسودہ نہیں۔ کسی کلام کے صفحے پر "ترمیم کریں" سے شروع کریں۔'],
...(me.role !== 'mod-l2' ? [['جائزے کے منتظر', queue.review, 'جائزے کے لیے کچھ نہیں۔']] : []), ...(me.role !== 'mod-l2' ? [['جائزے کے منتظر', queue.review, 'جائزے کے لیے کچھ نہیں۔']] : []),
@ -29,7 +31,7 @@ const groups = queue ? [
<ul class="lib-list"> <ul class="lib-list">
{items.map((r) => ( {items.map((r) => (
<li> <li>
<a class="lib-title" href={`/mod/rev/${r.id}`}>{r.title}</a> <a class="lib-title" href={`/mod/rev/${r.id}`}>{KIND[r.entity] ?? ''}{r.title}</a>
<span class={`status s-${r.status}`}>{STATUS[r.status]}</span> <span class={`status s-${r.status}`}>{STATUS[r.status]}</span>
<p class="muted small-line">{r.summary || 'بغیر خلاصہ'} · <bdi dir="ltr">{r.author_email}</bdi> · <bdi dir="ltr">{when(r.updated_at)}</bdi></p> <p class="muted small-line">{r.summary || 'بغیر خلاصہ'} · <bdi dir="ltr">{r.author_email}</bdi> · <bdi dir="ltr">{when(r.updated_at)}</bdi></p>
</li> </li>
@ -47,7 +49,7 @@ const groups = queue ? [
<td><bdi dir="ltr">{when(e.at)}</bdi></td> <td><bdi dir="ltr">{when(e.at)}</bdi></td>
<td><bdi dir="ltr">{e.actor_email}</bdi></td> <td><bdi dir="ltr">{e.actor_email}</bdi></td>
<td>{EVENT[e.action] ?? e.action}{e.version && e.action === 'published' ? ` (ورژن ${ud(e.version)})` : ''}</td> <td>{EVENT[e.action] ?? e.action}{e.version && e.action === 'published' ? ` (ورژن ${ud(e.version)})` : ''}</td>
<td><a href={`/mod/rev/${e.revision}`}>{e.title}</a></td> <td><a href={`/mod/rev/${e.revision}`}>{KIND[e.entity] ?? ''}{e.title}</a></td>
<td>{e.comment}</td> <td>{e.comment}</td>
</tr> </tr>
))} ))}