bulltrackers-module 1.0.128 → 1.0.129

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.
@@ -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
- for (const blockDocRef of blockDocRefs) {
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
- const partDocs = await withRetry(() => partsCollectionRef.listDocuments(), `listDocuments(${partsCollectionRef.path})`);
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
- for (const blockDocRef of blockDocRefs) {
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
- const partDocs = await withRetry(() => partsCollectionRef.listDocuments(), `listDocuments(${partsCollectionRef.path})`);
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.128",
3
+ "version": "1.0.129",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [