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
- yesterdayInsightsData = await loadDailyInsights(config, dependencies, prevStr);
262
- if(yesterdayInsightsData) {
263
- logger.log('INFO', `[${passName}] Loaded yesterday's (${prevStr}) insights data.`);
264
- } else {
265
- logger.log('WARN', `[${passName}] Yesterday's (${prevStr}) insights data not found. Insights calcs requiring it will be skipped.`);
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 ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.66",
3
+ "version": "1.0.67",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [