TransHub_backend / restore-week1-task1.js
linguabot's picture
Upload folder using huggingface_hub
da819ac verified
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 restoreWeek1Task1() {
try {
console.log('🌐 Connecting to MongoDB...');
await mongoose.connect(MONGODB_URI);
console.log('βœ… Connected to MongoDB');
// Check current Week 1 tasks
console.log('πŸ“‹ Current Week 1 tutorial tasks:');
const currentWeek1Tasks = await SourceText.find({
category: 'tutorial',
weekNumber: 1
}).sort({ title: 1 });
currentWeek1Tasks.forEach((task, index) => {
console.log(`${index + 1}. ${task.title}`);
});
// Create the missing first Week 1 tutorial task
const missingTask1 = {
title: 'Tutorial Task 1 - Gulangyu Stone',
content: 'The ancient stone carvings on Gulangyu Island tell stories of maritime trade and cultural exchange. These weathered stones, bearing inscriptions in multiple languages, serve as silent witnesses to centuries of cross-cultural communication.',
sourceLanguage: 'English',
sourceCulture: 'Chinese',
category: 'tutorial',
weekNumber: 1,
translationBrief: 'Translate this description of Gulangyu stone carvings for an international audience, emphasizing the historical significance and cultural heritage value.',
difficulty: 'intermediate',
tags: ['cultural heritage', 'historical', 'maritime trade'],
targetCultures: ['Western', 'International'],
isActive: true,
isProtected: true,
protectedReason: 'Week 1 tutorial tasks are locked to prevent accidental changes',
lastModified: new Date(),
modificationHistory: [
{
action: 'CREATED',
timestamp: new Date(),
reason: 'Restored missing Week 1 Tutorial Task 1'
}
]
};
// Check if the task already exists
const existingTask = await SourceText.findOne({
title: 'Tutorial Task 1 - Gulangyu Stone',
category: 'tutorial',
weekNumber: 1
});
if (existingTask) {
console.log('⚠️ Task already exists: Tutorial Task 1 - Gulangyu Stone');
console.log(` ID: ${existingTask._id}`);
console.log(` Protected: ${existingTask.isProtected ? 'YES' : 'NO'}`);
} else {
// Create the missing task
const newTask = await SourceText.create(missingTask1);
console.log('βœ… Created missing task: Tutorial Task 1 - Gulangyu Stone');
console.log(` ID: ${newTask._id}`);
console.log(` Protected: ${newTask.isProtected ? 'YES' : 'NO'}`);
}
// Show updated Week 1 tasks
console.log('\nπŸ“‹ Updated Week 1 tutorial tasks:');
const updatedWeek1Tasks = await SourceText.find({
category: 'tutorial',
weekNumber: 1
}).sort({ title: 1 });
updatedWeek1Tasks.forEach((task, index) => {
console.log(`${index + 1}. ${task.title}`);
console.log(` ID: ${task._id}`);
console.log(` Protected: ${task.isProtected ? 'YES' : 'NO'}`);
});
console.log(`\nπŸŽ‰ Week 1 now has ${updatedWeek1Tasks.length} tutorial tasks`);
} catch (error) {
console.error('❌ Error restoring Week 1 Task 1:', error);
} finally {
await mongoose.disconnect();
console.log('πŸ”Œ Disconnected from MongoDB');
}
}
restoreWeek1Task1();