metallkart-erp/scripts/cleanup-test-tasks.ts
louis 122b07a880 docs: session 148 rapports + artefact D1-D5 + CLAUDE.md update
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-29 20:07:29 +04:00

33 lines
1.1 KiB
TypeScript

import { PrismaClient } from '@prisma/client';
const p = new PrismaClient();
async function main() {
const tasks = await p.task.findMany({
where: { source: 'AGENT_AVGUST' },
select: { id: true, title: true, dueDate: true },
});
console.log(`Tasks AGENT_AVGUST: ${tasks.length}`);
for (const t of tasks) console.log(` - ${t.title} (${t.dueDate?.toISOString().slice(0, 10) ?? 'no date'})`);
if (tasks.length > 0) {
const { count } = await p.reminder.deleteMany({ where: { task: { source: 'AGENT_AVGUST' } } });
console.log(`Reminders deleted: ${count}`);
const del = await p.task.deleteMany({ where: { source: 'AGENT_AVGUST' } });
console.log(`Tasks deleted: ${del.count}`);
}
const reminders = await p.reminder.findMany({
where: { source: 'AGENT_AVGUST' },
select: { id: true, customMessage: true },
});
if (reminders.length > 0) {
console.log(`Standalone reminders: ${reminders.length}`);
await p.reminder.deleteMany({ where: { source: 'AGENT_AVGUST' } });
console.log('Deleted');
}
console.log('Cleanup done');
}
main().finally(() => p.$disconnect());