feat: enhance notification and reminder services with logging and time tracking
This commit is contained in:
@@ -51,10 +51,28 @@ class NotifikasiWaService {
|
||||
existing = [];
|
||||
}
|
||||
|
||||
existing.push(data);
|
||||
// 👉 selalu tambahkan waktu saat insert
|
||||
const now = new Date();
|
||||
|
||||
const newData = {
|
||||
...data,
|
||||
time: now.toLocaleTimeString('id-ID', {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: false,
|
||||
}),
|
||||
created_at: now.toISOString() // opsional (full timestamp)
|
||||
};
|
||||
|
||||
existing.push(newData);
|
||||
|
||||
await fs.writeFile(filePath, JSON.stringify(existing, null, 2), 'utf-8');
|
||||
|
||||
await this.saveLogReminder({
|
||||
message: `Reminder berhasil disimpan`,
|
||||
data
|
||||
})
|
||||
|
||||
console.log(`Reminder berhasil disimpan`);
|
||||
} catch (error) {
|
||||
console.log('Error saveReminder:', error);
|
||||
@@ -81,7 +99,20 @@ class NotifikasiWaService {
|
||||
existing = [];
|
||||
}
|
||||
|
||||
existing.push(data);
|
||||
// 👉 selalu tambahkan waktu saat insert
|
||||
const now = new Date();
|
||||
|
||||
const newData = {
|
||||
...data,
|
||||
time: now.toLocaleTimeString('id-ID', {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: false,
|
||||
}),
|
||||
created_at: now.toISOString() // opsional (full timestamp)
|
||||
};
|
||||
|
||||
existing.push(newData);
|
||||
|
||||
await fs.writeFile(filePathLog, JSON.stringify(existing, null, 2), 'utf-8');
|
||||
|
||||
@@ -235,6 +266,10 @@ class NotifikasiWaService {
|
||||
|
||||
this.saveReminder(newData);
|
||||
|
||||
await this.saveLogReminder({
|
||||
message: `Reminder ${id} berhasil dihapus`
|
||||
})
|
||||
|
||||
console.log(`Reminder ${id} berhasil dihapus`);
|
||||
return true;
|
||||
}
|
||||
@@ -471,6 +506,11 @@ class NotifikasiWaService {
|
||||
param.bodyMessage
|
||||
);
|
||||
|
||||
await this.saveLogReminder({
|
||||
message: `Reminder dijalankan`,
|
||||
resultSend
|
||||
})
|
||||
|
||||
await updateNotificationErrorUserDb(
|
||||
resultNotificationErrorUser[0].notification_error_user_id,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user