23 lines
872 B
TypeScript
23 lines
872 B
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
const jobId = process.argv[2] || '87c804c2-fbab-4547-8bac-7aebab530aa6';
|
|
const log = await prisma.emailLog.findFirst({
|
|
where: {
|
|
emailType: 'JOB_COMPLETED',
|
|
metadata: { path: ['jobId'], equals: jobId },
|
|
},
|
|
orderBy: { sentAt: 'desc' },
|
|
});
|
|
console.log('EmailLog for job', jobId, ':', log ? { status: log.status, sentAt: log.sentAt, resendMessageId: log.resendMessageId, errorMessage: log.errorMessage } : 'none');
|
|
const recent = await prisma.emailLog.findMany({
|
|
where: { emailType: 'JOB_COMPLETED' },
|
|
orderBy: { sentAt: 'desc' },
|
|
take: 5,
|
|
});
|
|
console.log('Last 5 JOB_COMPLETED:', recent.map((r) => ({ jobId: (r.metadata as any)?.jobId, status: r.status, sentAt: r.sentAt })));
|
|
await prisma.$disconnect();
|
|
}
|
|
main();
|