- Restructure operator sidebar into a flat task list with indented children; fold plan topology into plan ladders - Expand member catalog non-plan section to all published non-tier products; require recurring Stripe-mapped prices for purchase - Add operator domains placements and terminal-claims ledger; redirect /domains to the FedWiki Sites Domains anchor - Apply canonical vocabulary and chrome/form conventions; migrate seeded FedWiki Sites display name
73 lines
2.6 KiB
SQL
73 lines
2.6 KiB
SQL
-- name: GetProductByID :one
|
|
SELECT * FROM core.products
|
|
WHERE product_id = $1;
|
|
|
|
-- name: GetProductByName :one
|
|
SELECT * FROM core.products
|
|
WHERE name = $1;
|
|
|
|
-- name: ListActiveProducts :many
|
|
SELECT * FROM core.products
|
|
WHERE is_active = TRUE
|
|
ORDER BY name ASC;
|
|
|
|
-- name: ListPublicProducts :many
|
|
SELECT * FROM core.products
|
|
WHERE is_active = TRUE AND is_public = TRUE AND lifecycle_status = 'published'
|
|
ORDER BY name ASC;
|
|
|
|
-- name: ListPublicPlanProducts :many
|
|
-- Plan products are those attached to a ladder via plan_ladder_tiers
|
|
-- (Doc 31 Amendment #3); membership is the structural signal —
|
|
-- display_category is presentation-only and never branched on.
|
|
SELECT p.* FROM core.products p
|
|
WHERE p.is_active = TRUE AND p.is_public = TRUE AND p.lifecycle_status = 'published'
|
|
AND EXISTS (
|
|
SELECT 1 FROM core.plan_ladder_tiers t WHERE t.product_id = p.product_id
|
|
)
|
|
ORDER BY p.name ASC;
|
|
|
|
-- name: ListAllProducts :many
|
|
SELECT * FROM core.products
|
|
ORDER BY name ASC;
|
|
|
|
-- name: CreateProduct :one
|
|
INSERT INTO core.products (name, description, display_category, is_active, is_public, entitlement_set_id, lifecycle_status)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
RETURNING *;
|
|
|
|
-- name: UpdateProduct :one
|
|
UPDATE core.products
|
|
SET name = $2, description = $3, display_category = $4, is_active = $5, is_public = $6, entitlement_set_id = $7, metadata = $8
|
|
WHERE product_id = $1
|
|
RETURNING *;
|
|
|
|
-- name: CountPublishedProducts :one
|
|
-- Operator overview tile: the size of the live catalog. Counts only
|
|
-- lifecycle_status='published' — drafts are work in progress and retired
|
|
-- products are history, so neither belongs in a "what we sell today" number.
|
|
SELECT COUNT(*) FROM core.products
|
|
WHERE lifecycle_status = 'published';
|
|
|
|
-- name: GetProductShape :one
|
|
-- Diagnostics view (migration 00006): independent structural dimensions per
|
|
-- product. Readiness reads set_present and billing_shape.
|
|
SELECT * FROM core.product_shape
|
|
WHERE product_id = $1;
|
|
|
|
-- name: AnyProduct :one
|
|
-- Setup-checklist existence probe.
|
|
SELECT EXISTS(SELECT 1 FROM core.products);
|
|
|
|
-- name: AnyPublishedProduct :one
|
|
-- Setup-checklist existence probe.
|
|
SELECT EXISTS(SELECT 1 FROM core.products WHERE lifecycle_status = 'published');
|
|
|
|
-- name: CountPublishedTierProducts :one
|
|
-- Operator catalog overview (ux-ia-naming 2.1): how many published products
|
|
-- are a tier on some plan ladder, vs. off-ladder. A product counts once even
|
|
-- when it is shared across more than one ladder (DISTINCT).
|
|
SELECT COUNT(DISTINCT t.product_id) FROM core.plan_ladder_tiers t
|
|
JOIN core.products p ON p.product_id = t.product_id
|
|
WHERE p.lifecycle_status = 'published';
|