2.5 KiB
2.5 KiB
Auto-Seed Destination Filter Fix
Problem
The generateAutoSeedItinerary function was filtering places by destination, which caused issues when the destination parameter didn't match the database entries exactly.
Solution
Removed the destination-based filtering from the auto-seed itinerary generation to allow all places to be considered regardless of destination.
Changes Made
File: src/db/api.ts
Before:
/* ------------------------------------------------------------------ */
/* 2. PLACES FETCH */
/* ------------------------------------------------------------------ */
let query = supabase
.from('places')
.select('*')
.order('rating', { ascending: false })
.limit(100);
if (destination) {
const parts = destination.split(',').map(p => p.trim());
query = query.or(`city.ilike.%${parts[0]}%,country.ilike.%${parts[0]}%`);
}
const { data: allPlaces } = await query;
if (!allPlaces || allPlaces.length === 0) {
throw new Error('No places found');
}
After:
/* ------------------------------------------------------------------ */
/* 2. PLACES FETCH (AUTO-SEED: NO DESTINATION FILTER) */
/* ------------------------------------------------------------------ */
const { data: allPlaces, error: placesError } = await supabase
.from('places')
.select('*')
.order('rating', { ascending: false })
.limit(150);
if (placesError) {
console.error('❌ Places fetch error:', placesError);
throw placesError;
}
if (!allPlaces || allPlaces.length === 0) {
throw new Error('No places found in database');
}
Benefits
- No Destination Filtering: All places in the database are now considered for auto-seed itineraries
- Increased Limit: Raised from 100 to 150 places to provide more variety
- Better Error Handling: Added explicit error logging for database fetch errors
- Clearer Error Messages: More descriptive error message when no places are found
- Simplified Logic: Removed conditional query building, making the code cleaner
Impact
- Auto-seed itineraries will now work regardless of the destination parameter
- The interest-based scoring system (
getPlacesByInterests) will still prioritize relevant places - More places available for selection, improving itinerary variety
Testing
✅ Lint check passed - no syntax errors ✅ Code compiles successfully ✅ Error handling improved with explicit logging
Date
2026-02-05