bulltrackers-module 1.0.128 → 1.0.130
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.
|
@@ -12,15 +12,25 @@ function checkRootDependencies(calcManifest, rootDataStatus) { if (!calcManifest
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/** Stage 3: Check root data availability for a date */
|
|
15
|
-
|
|
15
|
+
// --- START FIX ---
|
|
16
|
+
// The signature is changed from '{ logger, ...deps }' to 'dependencies'
|
|
17
|
+
// to ensure the full object is passed down.
|
|
18
|
+
async function checkRootDataAvailability(dateStr, config, dependencies) {
|
|
19
|
+
const { logger } = dependencies; // Destructure logger for local use
|
|
16
20
|
logger.log('INFO', `[PassRunner] Checking root data for ${dateStr}...`);
|
|
17
21
|
try {
|
|
18
|
-
const [portfolioRefs, insightsData, socialData, historyRefs] = await Promise.all([
|
|
22
|
+
const [portfolioRefs, insightsData, socialData, historyRefs] = await Promise.all([
|
|
23
|
+
getPortfolioPartRefs(config, dependencies, dateStr), // Pass full 'dependencies'
|
|
24
|
+
loadDailyInsights(config, dependencies, dateStr), // Pass full 'dependencies'
|
|
25
|
+
loadDailySocialPostInsights(config, dependencies, dateStr), // Pass full 'dependencies'
|
|
26
|
+
getHistoryPartRefs(config, dependencies, dateStr) // Pass full 'dependencies'
|
|
27
|
+
]);
|
|
19
28
|
const hasPortfolio = !!(portfolioRefs?.length), hasInsights = !!insightsData, hasSocial = !!socialData, hasHistory = !!(historyRefs?.length);
|
|
20
29
|
if (!(hasPortfolio||hasInsights||hasSocial||hasHistory)) { logger.log('WARN', `[PassRunner] No root data for ${dateStr}.`); return null; }
|
|
21
30
|
return { portfolioRefs: portfolioRefs||[], insightsData: insightsData||null, socialData: socialData||null, historyRefs: historyRefs||[], status: { hasPortfolio, hasInsights, hasSocial, hasHistory } };
|
|
22
31
|
} catch (err) { logger.log('ERROR', `[PassRunner] Error checking data for ${dateStr}`, { errorMessage: err.message }); return null; }
|
|
23
32
|
}
|
|
33
|
+
// --- END FIX ---
|
|
24
34
|
|
|
25
35
|
/** Stage 4: Fetch computed dependencies from Firestore */
|
|
26
36
|
async function fetchDependenciesForPass(dateStr, calcsInPass, fullManifest, config, { db, logger }) {
|
|
@@ -85,4 +95,4 @@ async function runMetaComputationPass(date, calcs, passName, config, deps, fetch
|
|
|
85
95
|
logger.log(success===calcs.length?'SUCCESS':'WARN', `[${passName}] Completed ${dStr}. Success: ${success}/${calcs.length}`);
|
|
86
96
|
}
|
|
87
97
|
|
|
88
|
-
module.exports = { groupByPass, checkRootDataAvailability, fetchDependenciesForPass, filterCalculations, runStandardComputationPass, runMetaComputationPass };
|
|
98
|
+
module.exports = { groupByPass, checkRootDataAvailability, fetchDependenciesForPass, filterCalculations, runStandardComputationPass, runMetaComputationPass };
|
|
@@ -28,11 +28,22 @@ async function getPortfolioPartRefs(config, deps, dateString) {
|
|
|
28
28
|
const blockDocRefs = await withRetry(() => blockDocsQuery.listDocuments(), `listDocuments(${collectionName})`);
|
|
29
29
|
if (!blockDocRefs.length) { logger.log('WARN', `No block documents in ${collectionName}`); continue; }
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
// --- START MODIFICATION ---
|
|
32
|
+
// Run all "listDocuments" calls in parallel instead of a sequential loop
|
|
33
|
+
const partsPromises = blockDocRefs.map(blockDocRef => {
|
|
32
34
|
const partsCollectionRef = blockDocRef.collection(config.snapshotsSubcollection).doc(dateString).collection(config.partsSubcollection);
|
|
33
|
-
|
|
35
|
+
// Each call is individually retried
|
|
36
|
+
return withRetry(() => partsCollectionRef.listDocuments(), `listDocuments(${partsCollectionRef.path})`);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Wait for all parallel queries to finish
|
|
40
|
+
const partDocArrays = await Promise.all(partsPromises);
|
|
41
|
+
|
|
42
|
+
// Flatten the arrays of arrays into the final list
|
|
43
|
+
partDocArrays.forEach(partDocs => {
|
|
34
44
|
allPartRefs.push(...partDocs);
|
|
35
|
-
}
|
|
45
|
+
});
|
|
46
|
+
// --- END MODIFICATION ---
|
|
36
47
|
}
|
|
37
48
|
|
|
38
49
|
logger.log('INFO', `Found ${allPartRefs.length} portfolio part refs for ${dateString}`);
|
|
@@ -132,11 +143,22 @@ async function getHistoryPartRefs(config, deps, dateString) {
|
|
|
132
143
|
const blockDocRefs = await withRetry(() => blockDocsQuery.listDocuments(), `listDocuments(${collectionName})`);
|
|
133
144
|
if (!blockDocRefs.length) { logger.log('WARN', `No block documents in ${collectionName}`); continue; }
|
|
134
145
|
|
|
135
|
-
|
|
146
|
+
// --- START MODIFICATION ---
|
|
147
|
+
// Run all "listDocuments" calls in parallel instead of a sequential loop
|
|
148
|
+
const partsPromises = blockDocRefs.map(blockDocRef => {
|
|
136
149
|
const partsCollectionRef = blockDocRef.collection(config.snapshotsSubcollection).doc(dateString).collection(config.partsSubcollection);
|
|
137
|
-
|
|
150
|
+
// Each call is individually retried
|
|
151
|
+
return withRetry(() => partsCollectionRef.listDocuments(), `listDocuments(${partsCollectionRef.path})`);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// Wait for all parallel queries to finish
|
|
155
|
+
const partDocArrays = await Promise.all(partsPromises);
|
|
156
|
+
|
|
157
|
+
// Flatten the arrays of arrays into the final list
|
|
158
|
+
partDocArrays.forEach(partDocs => {
|
|
138
159
|
allPartRefs.push(...partDocs);
|
|
139
|
-
}
|
|
160
|
+
});
|
|
161
|
+
// --- END MODIFICATION ---
|
|
140
162
|
}
|
|
141
163
|
|
|
142
164
|
logger.log('INFO', `Found ${allPartRefs.length} history part refs for ${dateString}`);
|
|
@@ -150,4 +172,4 @@ module.exports = {
|
|
|
150
172
|
loadDailyInsights,
|
|
151
173
|
loadDailySocialPostInsights,
|
|
152
174
|
getHistoryPartRefs,
|
|
153
|
-
};
|
|
175
|
+
};
|