bulltrackers-module 1.0.699 → 1.0.700
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.
|
@@ -216,6 +216,12 @@ async function fetchDependencies(date, calcs, config, deps, manifestLookup = {},
|
|
|
216
216
|
|
|
217
217
|
/**
|
|
218
218
|
* Fetches result series (Historical data) for lookbacks.
|
|
219
|
+
* @param {string} endDateStr - The end date for the series
|
|
220
|
+
* @param {string[]} calcNames - Original (case-sensitive) computation names
|
|
221
|
+
* @param {Object} manifestLookup - Map of normalizedName -> category
|
|
222
|
+
* @param {Object} config - Configuration object
|
|
223
|
+
* @param {Object} deps - Dependencies (db, logger)
|
|
224
|
+
* @param {number} lookbackDays - Number of days to look back
|
|
219
225
|
*/
|
|
220
226
|
async function fetchResultSeries(endDateStr, calcNames, manifestLookup, config, deps, lookbackDays) {
|
|
221
227
|
const { db, logger } = deps;
|
|
@@ -224,7 +230,7 @@ async function fetchResultSeries(endDateStr, calcNames, manifestLookup, config,
|
|
|
224
230
|
// Initialize results structure
|
|
225
231
|
calcNames.forEach(n => results[normalizeName(n)] = {});
|
|
226
232
|
|
|
227
|
-
// Generate Date List
|
|
233
|
+
// Generate Date List (going backwards from endDate)
|
|
228
234
|
const dates = [];
|
|
229
235
|
const d = new Date(endDateStr);
|
|
230
236
|
for (let i = 0; i < lookbackDays; i++) {
|
|
@@ -238,6 +244,7 @@ async function fetchResultSeries(endDateStr, calcNames, manifestLookup, config,
|
|
|
238
244
|
for (const rawName of calcNames) {
|
|
239
245
|
const norm = normalizeName(rawName);
|
|
240
246
|
const category = manifestLookup[norm] || 'analytics';
|
|
247
|
+
|
|
241
248
|
ops.push(async () => {
|
|
242
249
|
const val = await fetchSingleResult(db, { ...config, logger }, dateStr, rawName, category);
|
|
243
250
|
if (val && !isDataEmpty(val)) {
|
|
@@ -9,6 +9,16 @@ const { commitResults } = require('../persistence/ResultCommitter');
|
|
|
9
9
|
const { fetchResultSeries } = require('../data/DependencyFetcher');
|
|
10
10
|
const { getManifest } = require('../topology/ManifestLoader');
|
|
11
11
|
|
|
12
|
+
// [FIX] Load calculations package directly for manifest building during force runs
|
|
13
|
+
let _calculations = null;
|
|
14
|
+
function getCalculations() {
|
|
15
|
+
if (!_calculations) {
|
|
16
|
+
try { _calculations = require('aiden-shared-calculations-unified').calculations; }
|
|
17
|
+
catch (e) { _calculations = {}; }
|
|
18
|
+
}
|
|
19
|
+
return _calculations;
|
|
20
|
+
}
|
|
21
|
+
|
|
12
22
|
class MetaExecutor {
|
|
13
23
|
|
|
14
24
|
// =========================================================================
|
|
@@ -94,13 +104,17 @@ class MetaExecutor {
|
|
|
94
104
|
const { logger } = deps;
|
|
95
105
|
const calcs = [metadata]; // Treat single as list for helpers
|
|
96
106
|
|
|
107
|
+
// [FIX] Build manifestLookup using the actual calculations package (not config.calculationsDirectory)
|
|
108
|
+
const allManifests = getManifest([], getCalculations(), deps);
|
|
109
|
+
const manifestLookup = Object.fromEntries(allManifests.map(m => [normalizeName(m.name), m.category]));
|
|
110
|
+
|
|
97
111
|
// 1. Load Data using Shared Helpers
|
|
98
112
|
const [mappings, rankings, variableRoots, seriesData, piMasterList] = await Promise.all([
|
|
99
113
|
loader.loadMappings(),
|
|
100
114
|
loader.loadRankings(dateStr),
|
|
101
115
|
loadVariableRootData(loader, dateStr, calcs, logger),
|
|
102
|
-
loadSeriesData(loader, dateStr, calcs,
|
|
103
|
-
loader.loadPIMasterList()
|
|
116
|
+
loadSeriesData(loader, dateStr, calcs, manifestLookup, config, deps),
|
|
117
|
+
loader.loadPIMasterList()
|
|
104
118
|
]);
|
|
105
119
|
|
|
106
120
|
let rankingsYesterday = null;
|
|
@@ -213,7 +227,7 @@ async function loadSeriesData(loader, dateStr, calcs, manifestLookup, config, de
|
|
|
213
227
|
const rootRequests = {};
|
|
214
228
|
const depRequests = {}; // norm -> { days, originalName }
|
|
215
229
|
|
|
216
|
-
// 1. Aggregate Lookback Depths
|
|
230
|
+
// 1. Aggregate Lookback Depths from dependencySeries config
|
|
217
231
|
for (const c of calcs) {
|
|
218
232
|
if (c.rootDataSeries) {
|
|
219
233
|
Object.entries(c.rootDataSeries).forEach(([type, val]) => {
|
|
@@ -225,7 +239,6 @@ async function loadSeriesData(loader, dateStr, calcs, manifestLookup, config, de
|
|
|
225
239
|
Object.entries(c.dependencySeries).forEach(([name, val]) => {
|
|
226
240
|
const days = typeof val === 'object' ? val.lookback : val;
|
|
227
241
|
const norm = normalizeName(name);
|
|
228
|
-
// [FIX] Track BOTH normalized name (for dedup) AND original name (for Firestore lookup)
|
|
229
242
|
if (!depRequests[norm] || depRequests[norm].days < days) {
|
|
230
243
|
depRequests[norm] = { days, originalName: name };
|
|
231
244
|
}
|
|
@@ -252,12 +265,12 @@ async function loadSeriesData(loader, dateStr, calcs, manifestLookup, config, de
|
|
|
252
265
|
}
|
|
253
266
|
});
|
|
254
267
|
|
|
255
|
-
// 3. Fetch Dependency Series
|
|
256
|
-
// [FIX] Use ORIGINAL names for Firestore document lookup (case-sensitive)
|
|
268
|
+
// 3. Fetch Dependency Series (category comes from manifestLookup)
|
|
257
269
|
const depEntries = Object.values(depRequests);
|
|
258
270
|
if (depEntries.length > 0) {
|
|
259
271
|
const depOriginalNames = depEntries.map(e => e.originalName);
|
|
260
272
|
const maxDays = Math.max(...depEntries.map(e => e.days));
|
|
273
|
+
|
|
261
274
|
deps.logger.log('INFO', `[MetaExecutor] Loading up to ${maxDays}-day series for Dependencies: ${depOriginalNames.join(', ')}`);
|
|
262
275
|
seriesData.results = await fetchResultSeries(dateStr, depOriginalNames, manifestLookup, config, deps, maxDays);
|
|
263
276
|
}
|
|
@@ -13,6 +13,16 @@ const mathLayer = require('../layers/index');
|
|
|
13
13
|
const { performance } = require('perf_hooks');
|
|
14
14
|
const v8 = require('v8');
|
|
15
15
|
|
|
16
|
+
// [FIX] Load calculations package directly for manifest building
|
|
17
|
+
let _calculations = null;
|
|
18
|
+
function getCalculations() {
|
|
19
|
+
if (!_calculations) {
|
|
20
|
+
try { _calculations = require('aiden-shared-calculations-unified').calculations; }
|
|
21
|
+
catch (e) { _calculations = {}; }
|
|
22
|
+
}
|
|
23
|
+
return _calculations;
|
|
24
|
+
}
|
|
25
|
+
|
|
16
26
|
class StandardExecutor {
|
|
17
27
|
|
|
18
28
|
// =========================================================================
|
|
@@ -383,17 +393,16 @@ async function loadGlobalRoots(loader, dateStr, calcs, deps) {
|
|
|
383
393
|
|
|
384
394
|
async function loadSeriesData(loader, dateStr, calcs, config, deps) {
|
|
385
395
|
const rootReqs = {};
|
|
386
|
-
const depReqs = {}; // norm -> { days, originalName }
|
|
396
|
+
const depReqs = {}; // norm -> { days, originalName, category }
|
|
387
397
|
|
|
388
398
|
calcs.forEach(c => {
|
|
389
399
|
if (c.manifest.rootDataSeries) {
|
|
390
400
|
Object.entries(c.manifest.rootDataSeries).forEach(([k, v]) => rootReqs[k] = Math.max(rootReqs[k]||0, v.lookback||v));
|
|
391
401
|
}
|
|
392
402
|
if (c.manifest.dependencySeries) {
|
|
393
|
-
// [FIX] Track BOTH normalized name (for dedup) AND original name (for Firestore lookup)
|
|
394
403
|
Object.entries(c.manifest.dependencySeries).forEach(([k, v]) => {
|
|
395
404
|
const norm = normalizeName(k);
|
|
396
|
-
const days = v.lookback
|
|
405
|
+
const days = typeof v === 'object' ? v.lookback : v;
|
|
397
406
|
if (!depReqs[norm] || depReqs[norm].days < days) {
|
|
398
407
|
depReqs[norm] = { days, originalName: k };
|
|
399
408
|
}
|
|
@@ -411,14 +420,16 @@ async function loadSeriesData(loader, dateStr, calcs, config, deps) {
|
|
|
411
420
|
if (rootMap[key]) series.root[key] = (await loader.loadSeries(rootMap[key], dateStr, days)).data;
|
|
412
421
|
}));
|
|
413
422
|
|
|
414
|
-
// [FIX] Use
|
|
423
|
+
// [FIX] Use getCalculations() to load ALL computations for proper category lookup
|
|
415
424
|
const depEntries = Object.values(depReqs);
|
|
416
425
|
if (depEntries.length) {
|
|
417
426
|
const depOriginalNames = depEntries.map(e => e.originalName);
|
|
418
427
|
const maxDays = Math.max(...depEntries.map(e => e.days));
|
|
419
|
-
|
|
420
|
-
|
|
428
|
+
|
|
429
|
+
// Build lookup from ALL computations (empty productLines = load all)
|
|
430
|
+
const allManifests = getManifest([], getCalculations(), deps);
|
|
421
431
|
const lookup = Object.fromEntries(allManifests.map(m => [normalizeName(m.name), m.category]));
|
|
432
|
+
|
|
422
433
|
series.results = await fetchResultSeries(dateStr, depOriginalNames, lookup, config, deps, maxDays);
|
|
423
434
|
}
|
|
424
435
|
|