bulltrackers-module 1.0.142 → 1.0.144
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.
|
@@ -55,7 +55,21 @@ async function checkRootDataAvailability(dateStr, config, dependencies, earliest
|
|
|
55
55
|
// We return null to skip the entire day
|
|
56
56
|
return null;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* --- THIS IS THE FIX ---
|
|
61
|
+
* Rename keys to match what streamAndProcess (Stage 8) expects.
|
|
62
|
+
* 'insightsData' is renamed to 'todayInsights'.
|
|
63
|
+
* 'socialData' is renamed to 'todaySocialPostInsights'.
|
|
64
|
+
*/
|
|
65
|
+
return {
|
|
66
|
+
portfolioRefs,
|
|
67
|
+
todayInsights: insightsData, // <-- FIX
|
|
68
|
+
todaySocialPostInsights: socialData, // <-- FIX
|
|
69
|
+
historyRefs,
|
|
70
|
+
status: { hasPortfolio, hasInsights, hasSocial, hasHistory }
|
|
71
|
+
};
|
|
72
|
+
|
|
59
73
|
} catch (err) { logger.log('ERROR', `[PassRunner] Error checking data for ${dateStr}`, { errorMessage: err.message }); return null; }
|
|
60
74
|
}
|
|
61
75
|
|
|
@@ -168,12 +182,16 @@ function filterCalculations(standardCalcs, metaCalcs, rootDataStatus, existingRe
|
|
|
168
182
|
/** Stage 6: Initialize calculator instances */
|
|
169
183
|
function initializeCalculators(calcs, logger) { const state = {}; for (const c of calcs) { const name=normalizeName(c.name), Cl=c.class; if(typeof Cl==='function') try { const inst=new Cl(); inst.manifest=c; state[name]=inst; } catch(e){logger.warn(`Init failed ${name}`,{errorMessage:e.message}); state[name]=null;} else {logger.warn(`Class missing ${name}`); state[name]=null;} } return state; }
|
|
170
184
|
|
|
171
|
-
/** Stage 7: Load historical data required for calculations
|
|
172
|
-
|
|
185
|
+
/** * Stage 7: Load historical data required for calculations
|
|
186
|
+
* --- THIS FUNCTION IS NOW FIXED ---
|
|
187
|
+
*/
|
|
188
|
+
async function loadHistoricalData(date, calcs, config, deps, rootData) {
|
|
189
|
+
const { logger } = deps; // <--- THIS WAS THE MISSING LINE
|
|
190
|
+
const updated = {...rootData}, dStr=date.toISOString().slice(0,10); const tasks = [];
|
|
191
|
+
|
|
173
192
|
const needsYesterdayPortfolio = calcs.some(c => c.isHistorical && c.rootDataDependencies.includes('portfolio'));
|
|
174
193
|
const needsTodayHistory = calcs.some(c => c.rootDataDependencies.includes('history'));
|
|
175
194
|
const needsYesterdayHistory = calcs.some(c => c.isHistorical && c.rootDataDependencies.includes('history'));
|
|
176
|
-
// --- NEW: Add checks for historical insights and social ---
|
|
177
195
|
const needsYesterdayInsights = calcs.some(c => c.isHistorical && c.rootDataDependencies.includes('insights'));
|
|
178
196
|
const needsYesterdaySocial = calcs.some(c => c.isHistorical && c.rootDataDependencies.includes('social'));
|
|
179
197
|
|
|
@@ -196,7 +214,6 @@ async function loadHistoricalData(date, calcs, config, deps, rootData) { const u
|
|
|
196
214
|
updated.yesterdayHistoryData=await loadFullDayMap(config,deps,await getHistoryPartRefs(config,deps,prevStr));
|
|
197
215
|
})());
|
|
198
216
|
}
|
|
199
|
-
// --- NEW: Load historical insights/social ---
|
|
200
217
|
if(needsYesterdayInsights) {
|
|
201
218
|
tasks.push((async()=>{ const prev=new Date(date); prev.setUTCDate(prev.getUTCDate()-1); const prevStr=prev.toISOString().slice(0,10);
|
|
202
219
|
logger.log('INFO', `[PassRunner] Loading YESTERDAY insights data for ${prevStr}`);
|
|
@@ -221,6 +238,7 @@ async function loadHistoricalData(date, calcs, config, deps, rootData) { const u
|
|
|
221
238
|
async function streamAndProcess(dateStr, state, passName, config, deps, rootData) {
|
|
222
239
|
const { logger, calculationUtils } = deps;
|
|
223
240
|
// --- MODIFIED: yesterdayInsights/Social are now loaded by loadHistoricalData ---
|
|
241
|
+
// --- THIS WILL NOW WORK, as rootData contains 'todayInsights' from Stage 3 ---
|
|
224
242
|
const { todayInsights, yesterdayInsights, todaySocialPostInsights, yesterdaySocialPostInsights, todayHistoryData, yesterdayHistoryData, yesterdayPortfolios } = rootData;
|
|
225
243
|
|
|
226
244
|
// --- NEW: Check if streaming is even needed ---
|
|
@@ -237,6 +255,7 @@ async function streamAndProcess(dateStr, state, passName, config, deps, rootData
|
|
|
237
255
|
if(cat==='socialPosts'||cat==='insights') {
|
|
238
256
|
if (firstUser) {
|
|
239
257
|
logger.log('INFO', `[${passName}] Running non-streaming calc: ${name}`);
|
|
258
|
+
// --- This 'args' array will now receive the correct data ---
|
|
240
259
|
let args=[null,null,null,{...context, userType: 'n/a'},todayInsights,yesterdayInsights,todaySocialPostInsights,yesterdaySocialPostInsights,todayHistoryData,yesterdayHistoryData];
|
|
241
260
|
// Pass historical data if needed
|
|
242
261
|
if(calc.manifest.isHistorical) {
|
|
@@ -266,6 +285,7 @@ async function streamAndProcess(dateStr, state, passName, config, deps, rootData
|
|
|
266
285
|
// --- MODIFIED: Skip social/insights here, they ran above ---
|
|
267
286
|
if(isSocialOrInsights) continue;
|
|
268
287
|
|
|
288
|
+
// --- This 'args' array will now receive the correct data ---
|
|
269
289
|
let args=[p,null,uid,context,todayInsights,yesterdayInsights,todaySocialPostInsights,yesterdaySocialPostInsights,todayHistoryData,yesterdayHistoryData];
|
|
270
290
|
|
|
271
291
|
if(isHistorical){
|
|
@@ -287,7 +307,7 @@ async function runStandardComputationPass(date, calcs, passName, config, deps, r
|
|
|
287
307
|
// --- THIS IS THE CRITICAL CHANGE ---
|
|
288
308
|
// If 'calcs' is empty *because of the new filter*, this log won't even appear.
|
|
289
309
|
if (calcs.length === 0) {
|
|
290
|
-
logger.log('INFO', `[${passName}] No standard calcs to run for ${
|
|
310
|
+
logger.log('INFO', `[${passName}] No standard calcs to run for ${dStr} after filtering.`);
|
|
291
311
|
return;
|
|
292
312
|
}
|
|
293
313
|
// This log now only appears if there is *actually* work to do.
|