From a80a5aaa00fa4f5476c85f49142fa7c53392680a Mon Sep 17 00:00:00 2001 From: devthejo Date: Sun, 27 Jul 2025 09:02:06 +0200 Subject: [PATCH] fix(cleanup): increase time --- services/watchers/src/constants/time.js | 4 ++-- services/watchers/src/watchers/geodata-cleanup-cron.js | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/services/watchers/src/constants/time.js b/services/watchers/src/constants/time.js index 58fd799..1d34f82 100644 --- a/services/watchers/src/constants/time.js +++ b/services/watchers/src/constants/time.js @@ -9,8 +9,8 @@ module.exports = { SCAN_AUTO_ARCHIVE_CRON: "0 4 * * *", // At 4:00 RELATIVE_UNREGISTERED_RECONCILIATION_CRON: "0 4 * * *", // At 4:00 DEVICE_GEODATA_IOS_SILENT_PUSH_AGE: "24 hours", // When to send iOS silent push for heartbeat sync - DEVICE_GEODATA_NOTIFICATION_AGE: "36 hours", // When to send push notification - DEVICE_GEODATA_CLEANUP_AGE: "48 hours", // When to remove/clean data + DEVICE_GEODATA_NOTIFICATION_AGE: "48 hours", // When to send push notification + DEVICE_GEODATA_CLEANUP_AGE: "2 weeks", // When to remove/clean data } // cheat on https://crontab.guru/ diff --git a/services/watchers/src/watchers/geodata-cleanup-cron.js b/services/watchers/src/watchers/geodata-cleanup-cron.js index 4cae5c2..8a40716 100644 --- a/services/watchers/src/watchers/geodata-cleanup-cron.js +++ b/services/watchers/src/watchers/geodata-cleanup-cron.js @@ -69,7 +69,6 @@ module.exports = async function () { const data = JSON.parse(deviceData) const age = data.updatedAt ? now - data.updatedAt : Infinity - // Handle cleanup first (48h+) - this takes priority if (age > cleanupAge) { try { // Remove from hot storage @@ -94,11 +93,8 @@ module.exports = async function () { "Error cleaning device data" ) } - } - // Handle iOS silent push for heartbeat sync (24h+ but less than 36h) - else if (age > iosHeartbeatAge) { + } else if (age > iosHeartbeatAge) { try { - // Enqueue task to send iOS silent push for geolocation heartbeat sync await addTask(tasks.IOS_GEOLOCATION_HEARTBEAT_SYNC, { deviceId, }) @@ -113,9 +109,7 @@ module.exports = async function () { "Error enqueueing iOS geolocation heartbeat sync task" ) } - } - // Handle notification (36h+ but less than 48h) - only during 9-19h window - else if (age > notificationAge) { + } else if (age > notificationAge) { const notifiedKey = `${COLDGEODATA_NOTIFIED_KEY_PREFIX}${deviceId}` try {