EventBuzz_Backend/scripts/show-food-places.js

42 lines
1.5 KiB
JavaScript

require('dotenv').config();
const {
fetchFoodRecordForEvent,
getDbName,
getFoodCollectionName,
} = require('../src/utils/conciergeRecommendationDb');
(async () => {
try {
const eventId = process.argv[2] || '69ce3c91be56b4a3b09b2333';
const doc = await fetchFoodRecordForEvent(eventId);
if (!doc) {
console.log(`No food document found in ${getDbName()}.${getFoodCollectionName()}`);
process.exit(0);
}
const raw = doc.raw || doc;
console.log('Database:', getDbName());
console.log('Collection:', getFoodCollectionName());
console.log('Document ID:', raw._id);
console.log('Event ID:', raw.eventId);
console.log('Location:', raw.location);
console.log('Number of restaurants:', raw.restaurants?.length || 0);
console.log('\nRecommendations:\n', raw.recommendations || 'None');
console.log('');
console.log('Full document JSON:\n', JSON.stringify(raw, null, 2));
console.log('\nRestaurants sample (first 5):');
(raw.restaurants || []).slice(0, 5).forEach((p, i) => {
console.log(` ${i + 1}. ${p.name}`);
console.log(` Address: ${p.address}`);
console.log(` Rating: ${p.rating}/5 (${p.user_ratings_total} reviews)`);
console.log(` Cuisines: ${p.cuisines?.join(', ')}`);
console.log(` Distance: ${p.distance_meters ? (p.distance_meters / 1000).toFixed(2) + ' km' : 'N/A'}`);
console.log('');
});
} catch (e) {
console.error('Error:', e.message);
process.exit(1);
}
})();