- Marked multiple tasks as completed in TODO.md related to tag management features. - Replaced manual tag input with `TagInput` component in `CreateTaskForm`, `EditTaskForm`, and `QuickAddTask` for better UX. - Updated `TaskCard` to display tags using `TagDisplay` with color support. - Enhanced `TasksService` to manage task-tag relationships with CRUD operations. - Integrated tag management into the global context for better accessibility across components.
97 lines
2.9 KiB
TypeScript
97 lines
2.9 KiB
TypeScript
import { prisma } from '../services/database';
|
|
|
|
/**
|
|
* Script pour reset la base de données et supprimer les anciennes données
|
|
*/
|
|
async function resetDatabase() {
|
|
console.log('🗑️ Reset de la base de données...');
|
|
console.log('===================================');
|
|
|
|
try {
|
|
// Compter les tâches avant suppression
|
|
const beforeCount = await prisma.task.count();
|
|
const manualCount = await prisma.task.count({ where: { source: 'manual' } });
|
|
const remindersCount = await prisma.task.count({ where: { source: 'reminders' } });
|
|
|
|
console.log(`📊 État actuel:`);
|
|
console.log(` Total: ${beforeCount} tâches`);
|
|
console.log(` Manuelles: ${manualCount} tâches`);
|
|
console.log(` Rappels: ${remindersCount} tâches`);
|
|
console.log('');
|
|
|
|
// Supprimer toutes les tâches de synchronisation
|
|
const deletedTasks = await prisma.task.deleteMany({
|
|
where: {
|
|
source: 'reminders'
|
|
}
|
|
});
|
|
|
|
console.log(`✅ Supprimé ${deletedTasks.count} tâches de synchronisation`);
|
|
|
|
// Supprimer les logs de sync
|
|
const deletedLogs = await prisma.syncLog.deleteMany();
|
|
console.log(`✅ Supprimé ${deletedLogs.count} logs de synchronisation`);
|
|
|
|
// Supprimer les tags orphelins (optionnel)
|
|
const deletedTags = await prisma.tag.deleteMany();
|
|
console.log(`✅ Supprimé ${deletedTags.count} tags`);
|
|
|
|
// Compter après nettoyage
|
|
const afterCount = await prisma.task.count();
|
|
|
|
console.log('');
|
|
console.log('🎉 Base de données nettoyée !');
|
|
console.log(`📊 Résultat: ${afterCount} tâches restantes`);
|
|
|
|
// Afficher les tâches restantes
|
|
if (afterCount > 0) {
|
|
console.log('');
|
|
console.log('📋 Tâches restantes:');
|
|
const remainingTasks = await prisma.task.findMany({
|
|
include: {
|
|
taskTags: {
|
|
include: {
|
|
tag: true
|
|
}
|
|
}
|
|
},
|
|
orderBy: { createdAt: 'desc' }
|
|
});
|
|
|
|
remainingTasks.forEach((task, index) => {
|
|
const statusEmoji = {
|
|
'todo': '⏳',
|
|
'in_progress': '🔄',
|
|
'done': '✅',
|
|
'cancelled': '❌'
|
|
}[task.status] || '❓';
|
|
|
|
// Utiliser les relations TaskTag
|
|
const tags = task.taskTags ? task.taskTags.map(tt => tt.tag.name) : [];
|
|
|
|
const tagsStr = tags.length > 0 ? ` [${tags.join(', ')}]` : '';
|
|
|
|
console.log(` ${index + 1}. ${statusEmoji} ${task.title}${tagsStr}`);
|
|
});
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('❌ Erreur lors du reset:', error);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
// Exécuter le script
|
|
if (require.main === module) {
|
|
resetDatabase().then(() => {
|
|
console.log('');
|
|
console.log('✨ Reset terminé avec succès !');
|
|
process.exit(0);
|
|
}).catch((error) => {
|
|
console.error('💥 Erreur fatale:', error);
|
|
process.exit(1);
|
|
});
|
|
}
|
|
|
|
export { resetDatabase };
|