Merge pull request 'add: await in data filtering logic' (#50) from wisdom into main
Reviewed-on: #50
This commit is contained in:
@@ -281,7 +281,7 @@ class NotifikasiWaService {
|
||||
async runReminder() {
|
||||
setInterval(async () => {
|
||||
const now = new Date();
|
||||
let data = this.loadReminder();
|
||||
let data = await this.loadReminder();
|
||||
|
||||
data = data?.filter(async (item) => {
|
||||
|
||||
@@ -393,6 +393,7 @@ class NotifikasiWaService {
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const reminderAt = new Date(deviceReminder[0].reminder_at);
|
||||
const deviceName = new Date(deviceReminder[0].device_name);
|
||||
|
||||
// 🔹 ambil bulan & jam dalam timezone server
|
||||
const nowParts = new Intl.DateTimeFormat('en-US', {
|
||||
@@ -439,7 +440,7 @@ class NotifikasiWaService {
|
||||
|
||||
if (!checkNotifExist) {
|
||||
|
||||
const deviceNotification = await getSparepartsByYearlyDb(yearly);
|
||||
// const deviceNotification = await getSparepartsByYearlyDb(yearly);
|
||||
|
||||
const data = {
|
||||
error_code_id: yearly ?? chanel.value,
|
||||
@@ -455,6 +456,8 @@ class NotifikasiWaService {
|
||||
|
||||
await this.saveReminder({
|
||||
notification_log: resultNotificationError.notification_error_id,
|
||||
error_code_id: data['error_code_id'],
|
||||
error_chanel: data['error_chanel'],
|
||||
start_at: timeReminderString,
|
||||
interval: 1,
|
||||
max: 3,
|
||||
@@ -483,7 +486,7 @@ class NotifikasiWaService {
|
||||
|
||||
const bodyMessage =
|
||||
`Hai ${dataUser.contact_name || "-"},\n` +
|
||||
`Diberitahukan bahwa terdapat sparepart pada device "${deviceNotification?.device_name ?? "-"}" ` +
|
||||
`Diberitahukan bahwa terdapat sparepart pada device "${deviceName ?? "-"}" ` +
|
||||
`yang telah memasuki jadwal perawatan tahunan.\n` +
|
||||
`\nSilakan segera lakukan pengecekan dan perawatan untuk memastikan kinerja tetap optimal.` +
|
||||
`\nDetail sparepart dapat dilihat pada link berikut:\n${shortUrl}`;
|
||||
|
||||
Reference in New Issue
Block a user