Fix: forenkle channels-query, fjern ugyldig factoids.title referanse
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0d8521855f
commit
a6ca0f602d
1 changed files with 1 additions and 10 deletions
|
|
@ -10,21 +10,12 @@ export const load: PageServerLoad = async ({ locals }) => {
|
||||||
c.id,
|
c.id,
|
||||||
c.name,
|
c.name,
|
||||||
c.config,
|
c.config,
|
||||||
n.workspace_id,
|
pn.node_type AS parent_name,
|
||||||
p.name AS parent_name,
|
|
||||||
(SELECT count(*)::int FROM messages m WHERE m.channel_id = c.id) AS message_count,
|
(SELECT count(*)::int FROM messages m WHERE m.channel_id = c.id) AS message_count,
|
||||||
(SELECT max(m.created_at) FROM messages m WHERE m.channel_id = c.id) AS last_message_at
|
(SELECT max(m.created_at) FROM messages m WHERE m.channel_id = c.id) AS last_message_at
|
||||||
FROM channels c
|
FROM channels c
|
||||||
JOIN nodes n ON n.id = c.id
|
JOIN nodes n ON n.id = c.id
|
||||||
LEFT JOIN nodes pn ON pn.id = c.parent_id
|
LEFT JOIN nodes pn ON pn.id = c.parent_id
|
||||||
LEFT JOIN (
|
|
||||||
SELECT id, COALESCE(
|
|
||||||
(SELECT name FROM channels WHERE id = pn2.id),
|
|
||||||
(SELECT title FROM factoids WHERE id = pn2.id),
|
|
||||||
pn2.node_type
|
|
||||||
) AS name
|
|
||||||
FROM nodes pn2
|
|
||||||
) p ON p.id = c.parent_id
|
|
||||||
WHERE n.workspace_id = ${locals.workspace.id}
|
WHERE n.workspace_id = ${locals.workspace.id}
|
||||||
ORDER BY c.name
|
ORDER BY c.name
|
||||||
`;
|
`;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue