INNER CODE UNIT · JavaScript
staleTime
adeekshith/watomatic · functions/index.js:1434
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;
for (const userDoc of usersSnapshot.docs) {
const userId = userDoc.id;
const existingSubscription = userDoc.data().subscription;