Made some changes to how index pages are made

This commit is contained in:
Leon Mika 2025-02-16 14:06:45 +11:00
parent ba12398d2f
commit 573517565d
14 changed files with 259 additions and 56 deletions

View file

@ -10,4 +10,12 @@ INSERT INTO bundles (
SELECT * FROM bundles WHERE site_id = $1;
-- name: GetBundleWithID :one
SELECT * FROM bundles WHERE id = $1;
SELECT * FROM bundles WHERE id = $1;
-- name: GetSiteBundleInfo :many
WITH page_counts AS (
SELECT b.bundle_id, count(*) AS page_count FROM pages b WHERE b.site_id = $1 GROUP BY bundle_id
), index_pages AS (
SELECT p.id AS index_page_id, p.bundle_id FROM pages p WHERE p.site_id = $1 AND p.role = 'index'
)
SELECT b.bundle_id, b.page_count, p.index_page_id FROM page_counts b LEFT OUTER JOIN index_pages p ON b.bundle_id = p.bundle_id;

View file

@ -5,14 +5,15 @@ INSERT INTO pages (
name,
name_provenance,
title,
role,
post_type_id,
body,
state,
props,
role,
publish_date,
created_at,
updated_at
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $11)
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $12)
RETURNING id;
-- name: UpdatePage :exec
@ -22,13 +23,14 @@ UPDATE pages SET
name = $4,
name_provenance = $5,
title = $6,
role = $7,
body = $8,
state = $9,
props = $10,
publish_date = $11,
created_at = $12,
updated_at = $13
post_type_id = $7,
role = $8,
body = $9,
state = $10,
props = $11,
publish_date = $12,
created_at = $13,
updated_at = $14
WHERE id = $1;
-- name: ListPublishablePages :many