INNER CODE UNIT · JavaScript
lastUpdatedTimestamp
adeekshith/watomatic · functions/index.js:1473
const lastUpdatedTimestamp = existingSubscription.lastUpdated?._seconds * 1000 || 0;
const isStale = lastUpdatedTimestamp < staleTime;
const stateChanged = existingSubscription.subscriptionState !== latestSubscription.subscriptionState;
const lineItem = latestSubscription.lineItems?.[0];
const newExpiryTime = lineItem?.expiryTime ? new Date(lineItem.expiryTime).getTime() : 0;
const expiryChanged = existingSubscription.expiryTime !== newExpiryTime;
if (!isStale && !stateChanged && !expiryChanged) {
logger.info('Subscription data is fresh, skipping refresh', {
userId,
lastUpdated: lastUpdatedTimestamp,
currentState: existingSubscription.subscriptionState,
});
skipped++;
continue;
}