Fix "comment" will never include IDs "doctors that received email: ", improve logging
This commit is contained in:
@@ -20,13 +20,14 @@ export const POST = async (request: NextRequest) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const doctors = await sendOpenJobsEmails();
|
const doctors = await sendOpenJobsEmails();
|
||||||
|
const doctorIds = doctors?.join(', ') ?? '-';
|
||||||
console.info(
|
console.info(
|
||||||
'Successfully sent out open job notification emails to doctors',
|
`Successfully sent out open job notification emails to doctorIds: ${doctorIds}`,
|
||||||
);
|
);
|
||||||
await createNotificationLog({
|
await createNotificationLog({
|
||||||
action: NotificationAction.DOCTOR_NEW_JOBS,
|
action: NotificationAction.DOCTOR_NEW_JOBS,
|
||||||
status: 'SUCCESS',
|
status: 'SUCCESS',
|
||||||
comment: `doctors that received email: ${doctors}`,
|
comment: `doctors that received email: ${doctorIds}`,
|
||||||
});
|
});
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
@@ -35,7 +36,7 @@ export const POST = async (request: NextRequest) => {
|
|||||||
},
|
},
|
||||||
{ status: 200 },
|
{ status: 200 },
|
||||||
);
|
);
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
console.error(
|
console.error(
|
||||||
'Error sending out open job notification emails to doctors.',
|
'Error sending out open job notification emails to doctors.',
|
||||||
e,
|
e,
|
||||||
@@ -43,7 +44,7 @@ export const POST = async (request: NextRequest) => {
|
|||||||
await createNotificationLog({
|
await createNotificationLog({
|
||||||
action: NotificationAction.DOCTOR_NEW_JOBS,
|
action: NotificationAction.DOCTOR_NEW_JOBS,
|
||||||
status: 'FAIL',
|
status: 'FAIL',
|
||||||
comment: e?.message,
|
comment: e instanceof Error ? e.message : 'Unknown error',
|
||||||
});
|
});
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user