const mongoose = require('mongoose'); const SourceText = require('./models/SourceText'); // MongoDB connection const MONGODB_URI = process.env.MONGODB_URI || 'mongodb+srv://nothingyu:wSg3lbO1PkHiRMq9@sandbox.ecysggv.mongodb.net/?retryWrites=true&w=majority&appName=sandbox'; async function restoreWeek2Tasks() { try { console.log('🌐 Connecting to MongoDB...'); await mongoose.connect(MONGODB_URI); console.log('āœ… Connected to MongoDB'); // Original Week 2 tutorial tasks that should be restored const originalWeek2Tasks = [ { title: 'Tutorial ST 1 - Week 2', content: 'The early bird catches the worm.', category: 'tutorial', weekNumber: 2, sourceLanguage: 'English', sourceCulture: 'Western', difficulty: 'intermediate', translationBrief: 'Translate this proverb into Chinese, considering the visual elements in the image.', imageUrl: 'https://images.unsplash.com/photo-1444464666168-49d633b86797?w=800&h=600&fit=crop', imageAlt: 'A bird perched on a branch during sunrise' }, { title: 'Tutorial ST 2 - Week 2', content: 'Actions speak louder than words.', category: 'tutorial', weekNumber: 2, sourceLanguage: 'English', sourceCulture: 'Western', difficulty: 'intermediate', translationBrief: 'Translate this saying into Chinese, considering the visual context provided.', imageUrl: 'https://images.unsplash.com/photo-1557804506-669a67965ba0?w=800&h=600&fit=crop', imageAlt: 'People working together in a collaborative environment' }, { title: 'Tutorial ST 3 - Week 2', content: 'A picture is worth a thousand words.', category: 'tutorial', weekNumber: 2, sourceLanguage: 'English', sourceCulture: 'Western', difficulty: 'intermediate', translationBrief: 'Translate this saying into Chinese, considering the visual context of the image.', imageUrl: 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800&h=600&fit=crop', imageAlt: 'A beautiful landscape photograph showing mountains and lake' }, { title: 'Tutorial ST 4 - Week 2', content: 'Don\'t judge a book by its cover.', category: 'tutorial', weekNumber: 2, sourceLanguage: 'English', sourceCulture: 'Western', difficulty: 'intermediate', translationBrief: 'Translate this proverb into Chinese, considering the visual context.', imageUrl: 'https://images.unsplash.com/photo-1544716278-ca5e3f4abd8c?w=800&h=600&fit=crop', imageAlt: 'An old book with a worn cover' }, { title: 'Tutorial ST 5 - Week 2', content: 'Where there\'s a will, there\'s a way.', category: 'tutorial', weekNumber: 2, sourceLanguage: 'English', sourceCulture: 'Western', difficulty: 'intermediate', translationBrief: 'Translate this saying into Chinese, considering the visual context.', imageUrl: 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800&h=600&fit=crop', imageAlt: 'A mountain path leading to the summit' }, { title: 'Tutorial ST 6 - Week 2', content: 'Practice makes perfect.', category: 'tutorial', weekNumber: 2, sourceLanguage: 'English', sourceCulture: 'Western', difficulty: 'intermediate', translationBrief: 'Translate this saying into Chinese, considering the visual context.', imageUrl: 'https://images.unsplash.com/photo-1557804506-669a67965ba0?w=800&h=600&fit=crop', imageAlt: 'Someone practicing a musical instrument' }, { title: 'Tutorial ST 7 - Week 2', content: 'Better late than never.', category: 'tutorial', weekNumber: 2, sourceLanguage: 'English', sourceCulture: 'Western', difficulty: 'intermediate', translationBrief: 'Translate this saying into Chinese, considering the visual context.', imageUrl: 'https://images.unsplash.com/photo-1444464666168-49d633b86797?w=800&h=600&fit=crop', imageAlt: 'A clock showing late time' }, { title: 'Tutorial ST 8 - Week 2', content: 'Look before you leap.', category: 'tutorial', weekNumber: 2, sourceLanguage: 'English', sourceCulture: 'Western', difficulty: 'intermediate', translationBrief: 'Translate this saying into Chinese, considering the visual context.', imageUrl: 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800&h=600&fit=crop', imageAlt: 'A person looking over a cliff edge' }, { title: 'Tutorial ST 9 - Week 2', content: 'You can\'t teach an old dog new tricks.', category: 'tutorial', weekNumber: 2, sourceLanguage: 'English', sourceCulture: 'Western', difficulty: 'intermediate', translationBrief: 'Translate this saying into Chinese, considering the visual context.', imageUrl: 'https://images.unsplash.com/photo-1544716278-ca5e3f4abd8c?w=800&h=600&fit=crop', imageAlt: 'An older person learning something new' }, { title: 'Tutorial ST 10 - Week 2', content: 'The grass is always greener on the other side.', category: 'tutorial', weekNumber: 2, sourceLanguage: 'English', sourceCulture: 'Western', difficulty: 'intermediate', translationBrief: 'Translate this saying into Chinese, considering the visual context.', imageUrl: 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800&h=600&fit=crop', imageAlt: 'A fence separating two fields of grass' }, { title: 'Tutorial ST 11 - Week 2', content: 'Don\'t put all your eggs in one basket.', category: 'tutorial', weekNumber: 2, sourceLanguage: 'English', sourceCulture: 'Western', difficulty: 'intermediate', translationBrief: 'Translate this saying into Chinese, considering the visual context.', imageUrl: 'https://images.unsplash.com/photo-1557804506-669a67965ba0?w=800&h=600&fit=crop', imageAlt: 'Multiple baskets with eggs distributed among them' }, { title: 'Tutorial ST 12 - Week 2', content: 'A stitch in time saves nine.', category: 'tutorial', weekNumber: 2, sourceLanguage: 'English', sourceCulture: 'Western', difficulty: 'intermediate', translationBrief: 'Translate this saying into Chinese, considering the visual context.', imageUrl: 'https://images.unsplash.com/photo-1444464666168-49d633b86797?w=800&h=600&fit=crop', imageAlt: 'Someone sewing a small tear in fabric' } ]; console.log('šŸ”„ Restoring original 12 Week 2 tutorial tasks...'); let restoredCount = 0; for (const task of originalWeek2Tasks) { // Check if this task already exists const existingTask = await SourceText.findOne({ title: task.title, category: 'tutorial', weekNumber: 2 }); if (existingTask) { console.log(`āš ļø Task "${task.title}" already exists, skipping...`); } else { await SourceText.create(task); console.log(`āœ… Restored task: ${task.title}`); restoredCount++; } } console.log(`\nšŸŽ‰ RESTORE COMPLETE: Restored ${restoredCount} tasks`); console.log('šŸ“‹ All Week 2 tutorial tasks:'); const allTasks = await SourceText.find({ category: 'tutorial', weekNumber: 2 }).sort({ title: 1 }); allTasks.forEach((task, index) => { console.log(`${index + 1}. ${task.title}`); console.log(` Image: ${task.imageUrl || 'No image'}`); }); console.log(`\nšŸ“Š Total Week 2 tutorial tasks: ${allTasks.length}`); } catch (error) { console.error('āŒ Error restoring Week 2 tasks:', error); process.exit(1); } finally { await mongoose.disconnect(); console.log('šŸ”Œ Disconnected from MongoDB'); } } // Run the restore restoreWeek2Tasks();