Files
editor/supabase/migrations/20260227204328_backfill_empty_projects.sql
T
98c1d5247e feat: filter empty projects from public gallery (#125)
* feat(community): filter empty projects from public gallery

Add is_empty column to projects table so the public gallery only shows
projects with actual content. Scene graph emptiness is computed on save
and on creation, and a backfill migration marks existing non-empty
projects. Also cleans up import ordering, fixes README migration path,
and removes stale feedback table migration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Use ESNext modules and bundler resolution

Update packages/db tsconfig to emit ESNext modules and use 'bundler' moduleResolution. This enables modern ESM output and bundler-style resolution for the db package (keeps outDir and rootDir unchanged).

* feat(editor): add dark mode theme and grid visibility toggle

Add theme state to viewer store with light/dark modes, dark-aware
lighting and background colors, grid show/hide toggle in settings,
and theme toggle buttons in the sidebar.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add ground occluder, animated lighting & UI tweaks

Introduce a ground occluder and smoother animated lighting while adjusting editor UI and icons. Viewer: add GroundOccluder (uses polygon-clipping to union slab/zone polygons) and AnimatedBackground, integrate both into the Canvas; improve Lights to interpolate intensities/colors/ambient for smooth theme transitions. Editor: refactor sidebar header to support inline project title editing and move the theme toggle; replace some lucide icons with image assets and add a settings icon (apps/editor/public/icons/settings.png). Also add polygon-clipping to the viewer package dependencies.

* Update dark mode background color and clean up imports

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 23:49:48 -05:00

38 lines
1.2 KiB
SQL

-- Backfill script to update the is_empty flag for existing projects
-- This can be run multiple times safely as logic evolves
UPDATE projects p
SET is_empty = false
FROM (
-- 1. Get the latest model for each project
SELECT DISTINCT ON (project_id) project_id, scene_graph
FROM projects_models
WHERE deleted_at IS NULL
ORDER BY project_id, version DESC, created_at DESC
) latest_model
WHERE p.id = latest_model.project_id
AND p.is_empty = true -- Only process projects that are currently marked empty
AND latest_model.scene_graph IS NOT NULL
AND latest_model.scene_graph->'nodes' IS NOT NULL
AND (
-- Condition 1: More than 3 nodes
(SELECT count(*) FROM jsonb_object_keys(latest_model.scene_graph->'nodes')) > 3
OR
-- Condition 2 & 3: Iterate through nodes to check type and children
EXISTS (
SELECT 1
FROM jsonb_each(latest_model.scene_graph->'nodes') AS n(key, value)
WHERE
-- Not a default node type
(n.value->>'type' NOT IN ('site', 'building', 'level'))
OR
-- Or is a level node with > 0 children
(
n.value->>'type' = 'level'
AND jsonb_typeof(n.value->'children') = 'array'
AND jsonb_array_length(n.value->'children') > 0
)
)
);