20 lines
773 B
TypeScript
20 lines
773 B
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
const p = new PrismaClient();
|
|
|
|
async function main() {
|
|
const all = await p.reminder.findMany({
|
|
orderBy: { scheduledFor: 'desc' },
|
|
take: 10,
|
|
select: { id: true, customMessage: true, scheduledFor: true, status: true, source: true, targetUserId: true },
|
|
});
|
|
console.log(`All reminders (latest 10): ${all.length}`);
|
|
for (const r of all) {
|
|
console.log(` ${r.source} | ${r.status} | ${r.scheduledFor.toISOString().slice(0, 16)} | ${r.customMessage?.slice(0, 40)}`);
|
|
}
|
|
|
|
const old = await p.reminder.deleteMany({ where: { source: 'AUTO_FROM_TASK', status: 'SENT' } });
|
|
if (old.count > 0) console.log(`\nDeleted ${old.count} old AUTO_FROM_TASK SENT reminders`);
|
|
}
|
|
|
|
main().finally(() => p.$disconnect());
|