bulltrackers-module 1.0.146 → 1.0.147
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.
|
@@ -273,7 +273,13 @@ async function runStandardComputationPass(date, calcs, passName, config, deps, r
|
|
|
273
273
|
const fullRoot = await loadHistoricalData(date, calcs, config, deps, rootData);
|
|
274
274
|
const state = initializeCalculators(calcs, logger);
|
|
275
275
|
await streamAndProcess(dStr, state, passName, config, deps, fullRoot);
|
|
276
|
+
|
|
277
|
+
// ===================================================================
|
|
278
|
+
// === UPDATED CODE BLOCK 1 (runStandardComputationPass) START ===
|
|
279
|
+
// ===================================================================
|
|
280
|
+
|
|
276
281
|
let success = 0;
|
|
282
|
+
const failedCalcs = []; // <-- ADDED: Initialize failure tracking
|
|
277
283
|
const standardWrites = [];
|
|
278
284
|
const shardedWrites = {};
|
|
279
285
|
for (const name in state) {
|
|
@@ -304,8 +310,12 @@ async function runStandardComputationPass(date, calcs, passName, config, deps, r
|
|
|
304
310
|
}
|
|
305
311
|
} catch (e) {
|
|
306
312
|
logger.log('ERROR', `getResult failed ${name} for ${dStr}`, { err: e.message, stack: e.stack });
|
|
313
|
+
failedCalcs.push(name); // <-- ADDED: Track failure
|
|
307
314
|
}
|
|
308
315
|
}
|
|
316
|
+
|
|
317
|
+
// ( ... The sharded write logic remains unchanged ... )
|
|
318
|
+
|
|
309
319
|
if (standardWrites.length > 0) {
|
|
310
320
|
await commitBatchInChunks(config, deps, standardWrites, `${passName} Standard ${dStr}`);
|
|
311
321
|
}
|
|
@@ -330,7 +340,21 @@ async function runStandardComputationPass(date, calcs, passName, config, deps, r
|
|
|
330
340
|
await commitBatchInChunks(config, deps, shardedDocWrites, `${passName} Sharded ${docPath} ${dStr}`);
|
|
331
341
|
}
|
|
332
342
|
}
|
|
333
|
-
|
|
343
|
+
|
|
344
|
+
// --- MODIFIED: Add failed computations to the final log ---
|
|
345
|
+
const logMetadata = {};
|
|
346
|
+
if (failedCalcs.length > 0) {
|
|
347
|
+
logMetadata.failedComputations = failedCalcs;
|
|
348
|
+
}
|
|
349
|
+
logger.log(
|
|
350
|
+
success === calcs.length ? 'SUCCESS' : 'WARN',
|
|
351
|
+
`[${passName}] Completed ${dStr}. Success: ${success}/${calcs.length}`,
|
|
352
|
+
logMetadata // <-- MODIFIED: Add metadata to log
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
// ===================================================================
|
|
356
|
+
// === UPDATED CODE BLOCK 1 (runStandardComputationPass) END ===
|
|
357
|
+
// ===================================================================
|
|
334
358
|
}
|
|
335
359
|
|
|
336
360
|
/** Stage 10: Run meta computations */
|
|
@@ -342,12 +366,22 @@ async function runMetaComputationPass(date, calcs, passName, config, deps, fetch
|
|
|
342
366
|
}
|
|
343
367
|
logger.log('INFO', `[${passName}] Running ${dStr} with ${calcs.length} calcs.`);
|
|
344
368
|
const fullRoot = await loadHistoricalData(date, calcs, config, deps, rootData);
|
|
369
|
+
|
|
370
|
+
// ===================================================================
|
|
371
|
+
// === UPDATED CODE BLOCK 2 (runMetaComputationPass) START ===
|
|
372
|
+
// ===================================================================
|
|
373
|
+
|
|
345
374
|
let success = 0;
|
|
375
|
+
const failedCalcs = []; // <-- ADDED: Initialize failure tracking
|
|
346
376
|
const standardWrites = [];
|
|
347
377
|
const shardedWrites = {};
|
|
348
378
|
for (const mCalc of calcs) {
|
|
349
379
|
const name = normalizeName(mCalc.name), Cl = mCalc.class;
|
|
350
|
-
if (typeof Cl !== 'function') {
|
|
380
|
+
if (typeof Cl !== 'function') {
|
|
381
|
+
logger.log('ERROR', `Invalid class ${name}`);
|
|
382
|
+
failedCalcs.push(name); // <-- ADDED: Track failure (invalid class)
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
351
385
|
const inst = new Cl();
|
|
352
386
|
try {
|
|
353
387
|
const result = await Promise.resolve(inst.process(dStr, { ...deps, rootData: fullRoot }, config, fetchedDeps));
|
|
@@ -369,8 +403,12 @@ async function runMetaComputationPass(date, calcs, passName, config, deps, fetch
|
|
|
369
403
|
}
|
|
370
404
|
} catch (e) {
|
|
371
405
|
logger.log('ERROR', `Meta-calc failed ${name} for ${dStr}`, { err: e.message, stack: e.stack });
|
|
406
|
+
failedCalcs.push(name); // <-- ADDED: Track failure
|
|
372
407
|
}
|
|
373
408
|
}
|
|
409
|
+
|
|
410
|
+
// ( ... The sharded write logic remains unchanged ... )
|
|
411
|
+
|
|
374
412
|
if (standardWrites.length > 0) {
|
|
375
413
|
await commitBatchInChunks(config, deps, standardWrites, `${passName} Meta ${dStr}`);
|
|
376
414
|
}
|
|
@@ -387,7 +425,21 @@ async function runMetaComputationPass(date, calcs, passName, config, deps, fetch
|
|
|
387
425
|
await commitBatchInChunks(config, deps, shardedDocWrites, `${passName} Sharded ${collectionName} ${dStr}`);
|
|
388
426
|
}
|
|
389
427
|
}
|
|
390
|
-
|
|
428
|
+
|
|
429
|
+
// --- MODIFIED: Add failed computations to the final log ---
|
|
430
|
+
const logMetadata = {};
|
|
431
|
+
if (failedCalcs.length > 0) {
|
|
432
|
+
logMetadata.failedComputations = failedCalcs;
|
|
433
|
+
}
|
|
434
|
+
logger.log(
|
|
435
|
+
success === calcs.length ? 'SUCCESS' : 'WARN',
|
|
436
|
+
`[${passName}] Completed ${dStr}. Success: ${success}/${calcs.length}`,
|
|
437
|
+
logMetadata // <-- MODIFIED: Add metadata to log
|
|
438
|
+
);
|
|
439
|
+
|
|
440
|
+
// ===================================================================
|
|
441
|
+
// === UPDATED CODE BLOCK 2 (runMetaComputationPass) END ===
|
|
442
|
+
// ===================================================================
|
|
391
443
|
}
|
|
392
444
|
|
|
393
445
|
module.exports = { groupByPass, checkRootDataAvailability, fetchExistingResults, filterCalculations, runStandardComputationPass, runMetaComputationPass };
|