Merge pull request 'fix: update saveReminder method to handle reset logic for reminders' (#52) from wisdom into main
Reviewed-on: #52
This commit is contained in:
@@ -31,7 +31,7 @@ const filePathLog = path.join(process.cwd(), 'scheduler', 'log.json');
|
|||||||
|
|
||||||
class NotifikasiWaService {
|
class NotifikasiWaService {
|
||||||
|
|
||||||
async saveReminder(data) {
|
async saveReminder(data, isReset = false) {
|
||||||
console.log(`Reminder proses dibuat`);
|
console.log(`Reminder proses dibuat`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -64,7 +64,12 @@ class NotifikasiWaService {
|
|||||||
created_at: now.toISOString() // opsional (full timestamp)
|
created_at: now.toISOString() // opsional (full timestamp)
|
||||||
};
|
};
|
||||||
|
|
||||||
existing.push(newData);
|
if (!isReset) {
|
||||||
|
existing.push(newData);
|
||||||
|
} else {
|
||||||
|
existing = newData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
await fs.writeFile(filePath, JSON.stringify(existing, null, 2), 'utf-8');
|
await fs.writeFile(filePath, JSON.stringify(existing, null, 2), 'utf-8');
|
||||||
|
|
||||||
@@ -268,7 +273,7 @@ class NotifikasiWaService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.saveReminder(newData);
|
this.saveReminder(newData, true);
|
||||||
|
|
||||||
await this.saveLogReminder({
|
await this.saveLogReminder({
|
||||||
message: `Reminder ${id} berhasil dihapus`
|
message: `Reminder ${id} berhasil dihapus`
|
||||||
@@ -344,7 +349,7 @@ class NotifikasiWaService {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.saveReminder(data);
|
await this.saveReminder(data, true);
|
||||||
|
|
||||||
}, 60 * 1000);
|
}, 60 * 1000);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user