INNER CODE UNIT · JavaScript
checkWindow
adeekshith/watomatic · functions/index.js:1430
const checkWindow = 48 * 60 * 60 * 1000; // 48 hours
// Also find subscriptions that haven't been verified recently (missed RTDNs)
const staleThreshold = 24 * 60 * 60 * 1000; // 24 hours
const staleTime = now - staleThreshold;
const usersSnapshot = await admin.firestore()
.collection('users')
.where('subscription.isActive', '==', true)
.where('subscription.expiryTime', '<=', now + checkWindow)
.get();
logger.info(`Found ${usersSnapshot.size} subscriptions to refresh`);
let refreshed = 0;
let skipped = 0;
let errors = 0;