Spaces:
Sleeping
Sleeping
Download scripts/verify-map.js from shard-c6/green-guard-api: direct link, hf CLI and curl.
- Browser
- Download file 1.79 kB
-
https://huggingface.co/spaces/shard-c6/green-guard-api/resolve/main/scripts/verify-map.js
- Command line
-
hf download hf://spaces/shard-c6/green-guard-api/scripts/verify-map.js
-
curl -L -o verify-map.js https://huggingface.co/spaces/shard-c6/green-guard-api/resolve/main/scripts/verify-map.js
1.79 kB
| /** | |
| * Map Verification Script | |
| * Inserts a test "NGO Plantation" post with geospatial data. | |
| */ | |
| require('dotenv').config(); | |
| const { createClient } = require('@supabase/supabase-js'); | |
| const supabase = createClient( | |
| process.env.SUPABASE_URL, | |
| process.env.SUPABASE_SERVICE_ROLE_KEY | |
| ); | |
| async function verifyMapData() { | |
| console.log('๐บ๏ธ Seeding a test plantation post for map verification...'); | |
| // 1. Get Admin User | |
| const adminEmail = process.env.ADMIN_EMAIL || 'admin@greenguard.in'; | |
| const { data: admin } = await supabase.from('profiles').select('id').eq('email', adminEmail).single(); | |
| if (!admin) { | |
| console.error('โ Admin user not found. Please run seed-admin.js first.'); | |
| return; | |
| } | |
| // 2. Insert Plantation Post (Mumbai) | |
| const testPost = { | |
| author_id: admin.id, | |
| content: 'Special NGO Plantation Event! We just planted 50 saplings at Sanjay Gandhi National Park. ๐ณ', | |
| post_type: 'plantation', | |
| latitude: 19.2212, | |
| longitude: 72.9113, | |
| location: 'POINT(72.9113 19.2212)', | |
| address: 'Sanjay Gandhi National Park, Mumbai', | |
| image_urls: ['https://images.unsplash.com/photo-1542601906990-b4d3fb778b09?auto=format&fit=crop&q=80&w=800'] | |
| }; | |
| const { data, error } = await supabase.from('posts').insert(testPost).select().single(); | |
| if (error) { | |
| console.error('โ Failed to insert test post:', error.message); | |
| if (error.message.includes('column "post_type" does not exist')) { | |
| console.error('๐ This means the SQL migration was NOT successful.'); | |
| } | |
| } else { | |
| console.log('โ Success! Test plantation post created with ID:', data.id); | |
| console.log('๐ Location:', testPost.address); | |
| console.log('\n๐ Now refresh your /map page to see the new indigo marker!'); | |
| } | |
| } | |
| verifyMapData(); | |