bulltrackers-module 1.0.138 → 1.0.139
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.
|
@@ -25,17 +25,36 @@ async function runComputationPass(config, dependencies, computationManifest) {
|
|
|
25
25
|
logger.log('INFO', `🚀 Starting PASS ${passToRun}...`);
|
|
26
26
|
const yesterday = new Date(); yesterday.setUTCDate(yesterday.getUTCDate()-1);
|
|
27
27
|
const endDateUTC = new Date(Date.UTC(yesterday.getUTCFullYear(), yesterday.getUTCMonth(), yesterday.getUTCDate()));
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
// const earliestDates = await getEarliestDataDates(config, dependencies); // <-- 1. COMMENT OUT OR REMOVE THIS BROKEN CALL
|
|
30
|
+
|
|
31
|
+
// --- START: 2. NEW HARDCODED DATES (V2 - CORRECTED) ---
|
|
32
|
+
logger.log('INFO', 'Using hardcoded earliest data dates to bypass faulty discovery.');
|
|
33
|
+
|
|
34
|
+
// Use the exact dates you provided:
|
|
35
|
+
const earliestPortfolio = new Date('2025-09-25T00:00:00Z'); // Earliest of Normal (09-25) and Spec (09-29)
|
|
36
|
+
const earliestHistory = new Date('2025-11-05T00:00:00Z'); // Both Normal and Spec history
|
|
37
|
+
const earliestSocial = new Date('2025-10-30T00:00:00Z'); // daily_social_insights
|
|
38
|
+
const earliestInsights = new Date('2025-08-26T00:00:00Z'); // daily_instrument_insights (Your new date)
|
|
39
|
+
|
|
40
|
+
const earliestDates = {
|
|
41
|
+
portfolio: earliestPortfolio,
|
|
42
|
+
history: earliestHistory,
|
|
43
|
+
social: earliestSocial,
|
|
44
|
+
insights: earliestInsights, // <-- Use the real date
|
|
45
|
+
// Calculate absoluteEarliest based on all real data
|
|
46
|
+
absoluteEarliest: [earliestPortfolio, earliestHistory, earliestSocial, earliestInsights].reduce((a, b) => a < b ? a : b)
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
logger.log('INFO', `Hardcoded map: portfolio=${earliestDates.portfolio.toISOString().slice(0,10)}, history=${earliestDates.history.toISOString().slice(0,10)}, social=${earliestDates.social.toISOString().slice(0,10)}, insights=${earliestDates.insights.toISOString().slice(0,10)}`);
|
|
50
|
+
// --- END: NEW HARDCODED DATES ---
|
|
29
51
|
|
|
30
|
-
// --- REMOVE OLD/REPLACE WITH NEW LOGIC FOR PROBLEM 3 & 4 ---
|
|
31
|
-
// const firstDate = earliestDates.absoluteEarliest; // <-- REMOVE
|
|
32
|
-
// const startDateUTC = firstDate ? new Date(Date.UTC(firstDate.getUTCFullYear(), firstDate.getUTCMonth(), firstDate.getUTCDate())) : new Date(config.earliestComputationDate+'T00:00:00Z'); // <-- REMOVE
|
|
33
52
|
|
|
34
53
|
const passes = groupByPass(computationManifest);
|
|
35
54
|
const calcsInThisPass = passes[passToRun] || []; if (!calcsInThisPass.length) return logger.log('WARN', `[PassRunner] No calcs for Pass ${passToRun}. Exiting.`);
|
|
36
55
|
|
|
37
|
-
// ---
|
|
38
|
-
//
|
|
56
|
+
// --- 3. THIS LOGIC BLOCK (from our last fix) IS NOW CORRECT ---
|
|
57
|
+
// It will consume the clean, hardcoded 'earliestDates' map and work as intended.
|
|
39
58
|
const requiredRootData = new Set();
|
|
40
59
|
calcsInThisPass.forEach(c => {
|
|
41
60
|
(c.rootDataDependencies || []).forEach(dep => requiredRootData.add(dep));
|
|
@@ -43,18 +62,27 @@ async function runComputationPass(config, dependencies, computationManifest) {
|
|
|
43
62
|
|
|
44
63
|
let earliestStartDateForPass = null;
|
|
45
64
|
if (requiredRootData.size > 0) {
|
|
46
|
-
// Find the LATEST of the earliest dates for all required data types.
|
|
47
|
-
// e.g., If portfolio starts 09-25 and social starts 10-30, a calc
|
|
48
|
-
// needing both must start on 10-30.
|
|
49
65
|
let latestOfEarliestDates = new Date(0); // Start at epoch
|
|
66
|
+
const farFutureSentinelYear = 2999; // Keep as a safety check for any future issues
|
|
67
|
+
let hasAtLeastOneValidDate = false;
|
|
68
|
+
|
|
50
69
|
requiredRootData.forEach(dep => {
|
|
51
|
-
const earliestDateForDep = earliestDates[dep];
|
|
52
|
-
|
|
53
|
-
|
|
70
|
+
const earliestDateForDep = earliestDates[dep];
|
|
71
|
+
|
|
72
|
+
// This check is now just a safeguard
|
|
73
|
+
if (earliestDateForDep && earliestDateForDep.getUTCFullYear() < farFutureSentinelYear) {
|
|
74
|
+
if (earliestDateForDep > latestOfEarliestDates) {
|
|
75
|
+
latestOfEarliestDates = earliestDateForDep;
|
|
76
|
+
}
|
|
77
|
+
hasAtLeastOneValidDate = true;
|
|
78
|
+
} else if (earliestDateForDep) {
|
|
79
|
+
logger.log('INFO', `[PassRunner] Dependency '${dep}' is not available (date: ${earliestDateForDep.toISOString().slice(0, 10)}). Calcs requiring it will be skipped.`);
|
|
80
|
+
} else {
|
|
81
|
+
logger.log('WARN', `[PassRunner] Dependency '${dep}' has no earliest date defined in hardcoded map.`);
|
|
54
82
|
}
|
|
55
83
|
});
|
|
56
84
|
|
|
57
|
-
if (
|
|
85
|
+
if (hasAtLeastOneValidDate) {
|
|
58
86
|
earliestStartDateForPass = latestOfEarliestDates;
|
|
59
87
|
}
|
|
60
88
|
}
|
|
@@ -67,7 +95,7 @@ async function runComputationPass(config, dependencies, computationManifest) {
|
|
|
67
95
|
|
|
68
96
|
logger.log('INFO', `[PassRunner] Pass ${passToRun} requires data: [${Array.from(requiredRootData).join(', ')}].`);
|
|
69
97
|
logger.log('INFO', `[PassRunner] Determined start date for this pass: ${startDateUTC.toISOString().slice(0, 10)}`);
|
|
70
|
-
// --- END
|
|
98
|
+
// --- END OF LOGIC BLOCK ---
|
|
71
99
|
|
|
72
100
|
const allExpectedDates = getExpectedDateStrings(startDateUTC, endDateUTC);
|
|
73
101
|
const firstDayOfBackfill = allExpectedDates.length > 0 ? allExpectedDates[0] : null; // --- MOVED FROM ABOVE ---
|