bulltrackers-module 1.0.66 → 1.0.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -258,11 +258,26 @@ async function runUnifiedComputation(dateToProcess, calculationsToRun, passName,
|
|
|
258
258
|
|
|
259
259
|
// --- MODIFIED: Load yesterday's insights if needed ---
|
|
260
260
|
if(requiresYesterdayInsights) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
261
|
+
let daysAgo = 1;
|
|
262
|
+
const maxLookback = 30; // Or from config
|
|
263
|
+
|
|
264
|
+
while (!yesterdayInsightsData && daysAgo <= maxLookback) {
|
|
265
|
+
const prev = new Date(dateToProcess);
|
|
266
|
+
prev.setUTCDate(prev.getUTCDate() - daysAgo);
|
|
267
|
+
const prevStr = prev.toISOString().slice(0, 10);
|
|
268
|
+
|
|
269
|
+
// Keep trying to load data until we find some
|
|
270
|
+
yesterdayInsightsData = await loadDailyInsights(config, dependencies, prevStr);
|
|
271
|
+
|
|
272
|
+
if (yesterdayInsightsData) {
|
|
273
|
+
logger.log('INFO', `[${passName}] Found 'yesterday' insights data from ${daysAgo} day(s) ago (${prevStr}).`);
|
|
274
|
+
} else {
|
|
275
|
+
daysAgo++; // Try the previous day
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (!yesterdayInsightsData) {
|
|
280
|
+
logger.log('WARN', `[${passName}] Could not find any 'yesterday' insights data within a ${maxLookback} day lookback.`);
|
|
266
281
|
}
|
|
267
282
|
}
|
|
268
283
|
// --- END MODIFIED ---
|