From ce973b2b380a961af3100dcdd56c0006e81d2189 Mon Sep 17 00:00:00 2001 From: Apple Date: Mon, 1 Dec 2025 07:26:35 -0800 Subject: [PATCH] feat: add MicroDAO pinning - 4 platform districts always on top --- migrations/040_microdao_pinned_order.sql | 20 ++++++++++++++++++++ services/city-service/repo_city.py | 8 ++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 migrations/040_microdao_pinned_order.sql diff --git a/migrations/040_microdao_pinned_order.sql b/migrations/040_microdao_pinned_order.sql new file mode 100644 index 00000000..0ba18032 --- /dev/null +++ b/migrations/040_microdao_pinned_order.sql @@ -0,0 +1,20 @@ +-- Migration: Add pinning and ordering for MicroDAO cards +-- Purpose: Allow certain MicroDAOs (platform districts) to be pinned at the top of the list + +-- Add pinning columns +ALTER TABLE microdaos + ADD COLUMN IF NOT EXISTS is_pinned boolean DEFAULT false, + ADD COLUMN IF NOT EXISTS pinned_weight integer DEFAULT 0; + +-- Create index for efficient sorting +CREATE INDEX IF NOT EXISTS idx_microdaos_pinned ON microdaos (is_pinned DESC, pinned_weight ASC); + +-- Set pinned status for the 4 platform districts +UPDATE microdaos SET is_pinned = true, pinned_weight = 1 WHERE slug = 'daarion'; +UPDATE microdaos SET is_pinned = true, pinned_weight = 2 WHERE slug = 'energy-union'; +UPDATE microdaos SET is_pinned = true, pinned_weight = 3 WHERE slug = 'greenfood'; +UPDATE microdaos SET is_pinned = true, pinned_weight = 4 WHERE slug = 'soul-retreat-hub'; + +-- Also mark these as platforms if not already +UPDATE microdaos SET is_platform = true WHERE slug IN ('daarion', 'energy-union', 'greenfood', 'soul-retreat-hub'); + diff --git a/services/city-service/repo_city.py b/services/city-service/repo_city.py index 5a2b7786..e1d66179 100644 --- a/services/city-service/repo_city.py +++ b/services/city-service/repo_city.py @@ -1757,6 +1757,8 @@ async def get_microdaos(district: Optional[str] = None, q: Optional[str] = None, m.is_active, COALESCE(m.is_public, true) as is_public, COALESCE(m.is_platform, false) as is_platform, + COALESCE(m.is_pinned, false) as is_pinned, + COALESCE(m.pinned_weight, 0) as pinned_weight, m.parent_microdao_id, pm.slug as parent_microdao_slug, m.logo_url, @@ -1773,7 +1775,7 @@ async def get_microdaos(district: Optional[str] = None, q: Optional[str] = None, LEFT JOIN microdaos pm ON m.parent_microdao_id = pm.id WHERE {where_sql} GROUP BY m.id, oa.display_name, pm.slug - ORDER BY m.name + ORDER BY COALESCE(m.is_pinned, false) DESC, COALESCE(m.pinned_weight, 0) ASC, m.created_at ASC LIMIT ${len(params) + 1} OFFSET ${len(params) + 2} """ @@ -1838,6 +1840,8 @@ async def list_microdao_summaries( m.is_active, COALESCE(m.is_public, true) as is_public, COALESCE(m.is_platform, false) as is_platform, + COALESCE(m.is_pinned, false) as is_pinned, + COALESCE(m.pinned_weight, 0) as pinned_weight, m.parent_microdao_id, pm.slug as parent_microdao_slug, m.logo_url, @@ -1854,7 +1858,7 @@ async def list_microdao_summaries( LEFT JOIN microdaos pm ON m.parent_microdao_id = pm.id WHERE {where_sql} GROUP BY m.id, oa.display_name, pm.slug - ORDER BY m.name + ORDER BY COALESCE(m.is_pinned, false) DESC, COALESCE(m.pinned_weight, 0) ASC, m.created_at ASC LIMIT ${len(params) + 1} OFFSET ${len(params) + 2} """