bulltrackers-module 1.0.650 → 1.0.652
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.
|
@@ -205,7 +205,7 @@ async function executeDispatchTask(dateStr, pass, targetComputation, config, dep
|
|
|
205
205
|
const execDate = new Date(dateStr + 'T00:00:00Z');
|
|
206
206
|
const updates = (calcManifest.type === 'standard')
|
|
207
207
|
? await StandardExecutor.run(execDate, calcsToRun, `Pass ${pass}`, config, dependencies, rootData, existingResults, previousResults)
|
|
208
|
-
: await MetaExecutor.run(execDate, calcsToRun, `Pass ${pass}`, config, dependencies, existingResults, previousResults
|
|
208
|
+
: await MetaExecutor.run(execDate, calcsToRun, `Pass ${pass}`, config, dependencies, rootData, existingResults, previousResults);
|
|
209
209
|
|
|
210
210
|
return { date: dateStr, updates };
|
|
211
211
|
}
|
|
@@ -43,12 +43,26 @@ function isDataEmpty(data) {
|
|
|
43
43
|
* This fixes the 'fetchExistingResults is not a function' TypeError.
|
|
44
44
|
*/
|
|
45
45
|
async function fetchExistingResults(dateStr, calcs, fullManifest, config, deps, isHistoricalContext) {
|
|
46
|
+
const { logger } = deps;
|
|
47
|
+
|
|
48
|
+
// DEBUG: Log entry
|
|
49
|
+
logger.log('INFO', `[DependencyFetcher] 📥 fetchExistingResults called for date: ${dateStr}, calcs: ${calcs.length}, isHistorical: ${isHistoricalContext}`);
|
|
50
|
+
logger.log('INFO', `[DependencyFetcher] 📥 Calcs being processed: ${calcs.map(c => {
|
|
51
|
+
const name = c.name || c.constructor?.name || 'unknown';
|
|
52
|
+
const hasClass = !!c.class;
|
|
53
|
+
const classType = c.class ? (typeof c.class === 'function' ? 'function' : typeof c.class) : 'none';
|
|
54
|
+
return `${name} (has class: ${hasClass}, class type: ${classType})`;
|
|
55
|
+
}).join(', ')}`);
|
|
56
|
+
|
|
46
57
|
// 1. Build Manifest Lookup (Name -> Category)
|
|
47
58
|
const manifestLookup = {};
|
|
48
59
|
if (Array.isArray(fullManifest)) {
|
|
49
60
|
fullManifest.forEach(c => {
|
|
50
61
|
manifestLookup[normalizeName(c.name)] = c.category || 'analytics';
|
|
51
62
|
});
|
|
63
|
+
logger.log('INFO', `[DependencyFetcher] 📥 Built manifest lookup with ${Object.keys(manifestLookup).length} entries`);
|
|
64
|
+
} else {
|
|
65
|
+
logger.log('WARN', `[DependencyFetcher] ⚠️ fullManifest is not an array: ${typeof fullManifest}`);
|
|
52
66
|
}
|
|
53
67
|
|
|
54
68
|
// 2. Convert Date String to Date Object
|
|
@@ -58,7 +72,13 @@ async function fetchExistingResults(dateStr, calcs, fullManifest, config, deps,
|
|
|
58
72
|
// 3. Delegate to fetchDependencies
|
|
59
73
|
// CRITICAL: For historical context (yesterday's data), allow missing dependencies
|
|
60
74
|
// Historical lookbacks are optional - gaps in historical data are permissible
|
|
61
|
-
|
|
75
|
+
const result = await fetchDependencies(dateObj, calcs, config, deps, manifestLookup, isHistoricalContext);
|
|
76
|
+
|
|
77
|
+
// DEBUG: Log result
|
|
78
|
+
const resultKeys = Object.keys(result);
|
|
79
|
+
logger.log('INFO', `[DependencyFetcher] 📤 fetchExistingResults returning ${resultKeys.length} dependencies: ${resultKeys.length > 0 ? resultKeys.join(', ') : 'NONE'}`);
|
|
80
|
+
|
|
81
|
+
return result;
|
|
62
82
|
}
|
|
63
83
|
|
|
64
84
|
/**
|
|
@@ -74,11 +94,27 @@ async function fetchDependencies(date, calcs, config, deps, manifestLookup = {},
|
|
|
74
94
|
const { db, logger } = deps;
|
|
75
95
|
const dStr = date.toISOString().slice(0, 10);
|
|
76
96
|
|
|
97
|
+
// DEBUG: Log entry
|
|
98
|
+
logger.log('INFO', `[DependencyFetcher] 🔍 fetchDependencies called with ${calcs.length} calc(s): ${calcs.map(c => c.name || c.constructor?.name || 'unknown').join(', ')}`);
|
|
99
|
+
|
|
77
100
|
// 1. Identify unique dependencies needed
|
|
78
101
|
// CHANGED: Use a Map to track { normalizedName: originalName }
|
|
79
102
|
const needed = new Map();
|
|
80
103
|
|
|
81
104
|
calcs.forEach(c => {
|
|
105
|
+
const calcName = c.name || c.constructor?.name || 'unknown';
|
|
106
|
+
|
|
107
|
+
// DEBUG: Log what we're checking
|
|
108
|
+
logger.log('INFO', `[DependencyFetcher] 🔍 Processing calc: ${calcName}`);
|
|
109
|
+
logger.log('INFO', `[DependencyFetcher] - has class: ${!!c.class}`);
|
|
110
|
+
logger.log('INFO', `[DependencyFetcher] - class type: ${c.class ? (typeof c.class === 'function' ? 'function' : typeof c.class) : 'none'}`);
|
|
111
|
+
logger.log('INFO', `[DependencyFetcher] - class.getDependencies: ${c.class && typeof c.class.getDependencies === 'function' ? 'YES' : 'NO'}`);
|
|
112
|
+
logger.log('INFO', `[DependencyFetcher] - has getDependencies: ${typeof c.getDependencies === 'function' ? 'YES' : 'NO'}`);
|
|
113
|
+
logger.log('INFO', `[DependencyFetcher] - has dependencies array: ${Array.isArray(c.dependencies) ? `YES (${c.dependencies.length} items)` : 'NO'}`);
|
|
114
|
+
if (Array.isArray(c.dependencies)) {
|
|
115
|
+
logger.log('INFO', `[DependencyFetcher] - dependencies array: ${c.dependencies.join(', ')}`);
|
|
116
|
+
}
|
|
117
|
+
|
|
82
118
|
// [FIX] Support both .getDependencies() method and .dependencies array
|
|
83
119
|
// CRITICAL: Prefer class.getDependencies() over manifest.dependencies
|
|
84
120
|
// because the class method returns original case-sensitive names,
|
|
@@ -87,26 +123,37 @@ async function fetchDependencies(date, calcs, config, deps, manifestLookup = {},
|
|
|
87
123
|
if (c.class && typeof c.class.getDependencies === 'function') {
|
|
88
124
|
// Use the class method - returns original case-sensitive names
|
|
89
125
|
reqs = c.class.getDependencies();
|
|
126
|
+
logger.log('INFO', `[DependencyFetcher] ✅ Using c.class.getDependencies() - returned: ${JSON.stringify(reqs)}`);
|
|
90
127
|
} else if (typeof c.getDependencies === 'function') {
|
|
91
128
|
// Fallback: direct method call (if c is the class itself)
|
|
92
129
|
reqs = c.getDependencies();
|
|
130
|
+
logger.log('INFO', `[DependencyFetcher] ✅ Using c.getDependencies() - returned: ${JSON.stringify(reqs)}`);
|
|
93
131
|
} else if (c.dependencies && Array.isArray(c.dependencies)) {
|
|
94
132
|
// Last resort: use manifest's dependencies array (normalized)
|
|
95
133
|
// This is less ideal because names are normalized, but we'll use them as-is
|
|
96
134
|
reqs = c.dependencies;
|
|
135
|
+
logger.log('INFO', `[DependencyFetcher] ⚠️ Using c.dependencies array (normalized) - returned: ${JSON.stringify(reqs)}`);
|
|
136
|
+
} else {
|
|
137
|
+
logger.log('WARN', `[DependencyFetcher] ❌ No way to get dependencies for ${calcName} - all methods failed`);
|
|
97
138
|
}
|
|
98
139
|
|
|
99
140
|
if (Array.isArray(reqs)) {
|
|
141
|
+
logger.log('INFO', `[DependencyFetcher] ✅ Found ${reqs.length} dependencies for ${calcName}: ${reqs.join(', ')}`);
|
|
100
142
|
reqs.forEach(r => {
|
|
101
143
|
// We map the normalized version to the original requested version
|
|
102
144
|
// This ensures we fetch the right file (normalized) but return it
|
|
103
145
|
// with the casing the user code expects (original).
|
|
104
146
|
needed.set(normalizeName(r), r);
|
|
105
147
|
});
|
|
148
|
+
} else {
|
|
149
|
+
logger.log('WARN', `[DependencyFetcher] ⚠️ reqs is not an array for ${calcName}: ${typeof reqs}`);
|
|
106
150
|
}
|
|
107
151
|
});
|
|
108
152
|
|
|
109
|
-
if (needed.size === 0)
|
|
153
|
+
if (needed.size === 0) {
|
|
154
|
+
logger.log('WARN', `[DependencyFetcher] ⚠️ No dependencies needed - returning empty object`);
|
|
155
|
+
return {};
|
|
156
|
+
}
|
|
110
157
|
|
|
111
158
|
const calcNames = calcs.map(c => c.name || c.constructor?.name || 'unknown').join(', ');
|
|
112
159
|
logger.log('INFO', `[DependencyFetcher] Fetching ${needed.size} dependencies for computation(s): ${calcNames} (date: ${dStr})`);
|