feat: add MicroDAO pinning - 4 platform districts always on top
This commit is contained in:
20
migrations/040_microdao_pinned_order.sql
Normal file
20
migrations/040_microdao_pinned_order.sql
Normal file
@@ -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');
|
||||
|
||||
@@ -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}
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user