bulltrackers-module 1.0.710 → 1.0.712
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.
- package/functions/api-v2/helpers/data-fetchers/firestore.js +119 -63
- package/functions/computation-system/data/CachedDataLoader.js +22 -1
- package/functions/computation-system/data/DependencyFetcher.js +118 -0
- package/functions/computation-system/persistence/ResultCommitter.js +94 -3
- package/functions/computation-system/utils/data_loader.js +244 -13
- package/functions/core/utils/bigquery_utils.js +1655 -0
- package/functions/core/utils/firestore_utils.js +99 -30
- package/functions/etoro-price-fetcher/helpers/handler_helpers.js +85 -13
- package/functions/fetch-insights/helpers/handler_helpers.js +26 -0
- package/functions/fetch-popular-investors/helpers/fetch_helpers.js +66 -0
- package/functions/price-backfill/helpers/handler_helpers.js +59 -10
- package/functions/root-data-indexer/index.js +79 -27
- package/functions/task-engine/helpers/data_storage_helpers.js +194 -102
- package/functions/task-engine/helpers/popular_investor_helpers.js +13 -7
- package/functions/task-engine/utils/bigquery_batch_manager.js +201 -0
- package/functions/task-engine/utils/firestore_batch_manager.js +21 -1
- package/index.js +34 -2
- package/package.json +3 -2
|
@@ -5,13 +5,20 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
const { FieldValue } = require('@google-cloud/firestore');
|
|
8
|
+
const { BigQueryBatchManager } = require('./bigquery_batch_manager');
|
|
8
9
|
|
|
9
10
|
class FirestoreBatchManager {
|
|
10
11
|
constructor(db, headerManager, logger, config) {
|
|
11
12
|
this.db = db;
|
|
12
13
|
this.headerManager = headerManager;
|
|
13
14
|
this.logger = logger;
|
|
14
|
-
this.config = config;
|
|
15
|
+
this.config = config;
|
|
16
|
+
|
|
17
|
+
// Initialize BigQuery batch manager (if enabled)
|
|
18
|
+
this.bigqueryBatchManager = null;
|
|
19
|
+
if (process.env.BIGQUERY_ENABLED !== 'false') {
|
|
20
|
+
this.bigqueryBatchManager = new BigQueryBatchManager(logger);
|
|
21
|
+
}
|
|
15
22
|
|
|
16
23
|
// State containers for batching
|
|
17
24
|
this.portfolioBatch = {};
|
|
@@ -316,9 +323,22 @@ class FirestoreBatchManager {
|
|
|
316
323
|
}
|
|
317
324
|
|
|
318
325
|
if (batchOps) await firestoreBatch.commit();
|
|
326
|
+
|
|
327
|
+
// Flush BigQuery batches (if enabled) - runs in parallel with Firestore
|
|
328
|
+
if (this.bigqueryBatchManager) {
|
|
329
|
+
await this.bigqueryBatchManager.flushBatches();
|
|
330
|
+
}
|
|
331
|
+
|
|
319
332
|
await this.headerManager.flushPerformanceUpdates();
|
|
320
333
|
this.logger.log('INFO', '[BATCH] All batches flushed successfully.');
|
|
321
334
|
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Get BigQuery batch manager (for adding rows from data_storage_helpers)
|
|
338
|
+
*/
|
|
339
|
+
getBigQueryBatchManager() {
|
|
340
|
+
return this.bigqueryBatchManager;
|
|
341
|
+
}
|
|
322
342
|
}
|
|
323
343
|
|
|
324
344
|
module.exports = { FirestoreBatchManager };
|
package/index.js
CHANGED
|
@@ -61,6 +61,10 @@ const { runBackfillAssetPrices } = require('./functions
|
|
|
61
61
|
const { runRootDataIndexer } = require('./functions/root-data-indexer/index');
|
|
62
62
|
// [NEW] Popular Investor Fetcher
|
|
63
63
|
const { runPopularInvestorFetch } = require('./functions/fetch-popular-investors/index');
|
|
64
|
+
// [NEW] Backfill Task Engine Data
|
|
65
|
+
const { backfillTaskEngineData } = require('./functions/maintenance/backfill-task-engine-data/index');
|
|
66
|
+
const { backfillPIMasterListRankings } = require('./functions/maintenance/backfill-pi-master-list-rankings/index');
|
|
67
|
+
const { backfillInstrumentInsights } = require('./functions/maintenance/backfill-instrument-insights/index');
|
|
64
68
|
|
|
65
69
|
// Alert System
|
|
66
70
|
const { handleAlertTrigger, handleComputationResultWrite, checkAndSendAllClearNotifications } = require('./functions/alert-system/index');
|
|
@@ -127,7 +131,11 @@ const maintenance = {
|
|
|
127
131
|
runBackfillAssetPrices,
|
|
128
132
|
runRootDataIndexer,
|
|
129
133
|
// [NEW] Added to maintenance pipe
|
|
130
|
-
runPopularInvestorFetch
|
|
134
|
+
runPopularInvestorFetch,
|
|
135
|
+
// [NEW] BigQuery backfills
|
|
136
|
+
backfillTaskEngineData,
|
|
137
|
+
backfillPIMasterListRankings,
|
|
138
|
+
backfillInstrumentInsights
|
|
131
139
|
};
|
|
132
140
|
|
|
133
141
|
const proxy = { handlePost };
|
|
@@ -140,4 +148,28 @@ const alertSystem = {
|
|
|
140
148
|
|
|
141
149
|
module.exports = {
|
|
142
150
|
pipe: { core, orchestrator, dispatcher, taskEngine, computationSystem, api, maintenance, proxy, alertSystem },
|
|
143
|
-
};
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// CLI handling: If running as a script with backfill arguments, execute the backfill
|
|
154
|
+
if (require.main === module) {
|
|
155
|
+
const args = process.argv.slice(2);
|
|
156
|
+
|
|
157
|
+
// Check if this looks like a backfill command (has --startDate or --endDate)
|
|
158
|
+
const isBackfillCommand = args.some(arg =>
|
|
159
|
+
arg.startsWith('--startDate=') ||
|
|
160
|
+
arg.startsWith('--endDate=') ||
|
|
161
|
+
arg.startsWith('--dataType=')
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
if (isBackfillCommand) {
|
|
165
|
+
// Route to backfill function
|
|
166
|
+
console.log('🚀 Starting backfill from main entry point...\n');
|
|
167
|
+
backfillTaskEngineData(null, null).catch(error => {
|
|
168
|
+
console.error('Fatal error:', error);
|
|
169
|
+
process.exit(1);
|
|
170
|
+
});
|
|
171
|
+
} else {
|
|
172
|
+
// No recognized command, just export (normal module behavior)
|
|
173
|
+
// This allows the file to still work as a module when imported
|
|
174
|
+
}
|
|
175
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bulltrackers-module",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.712",
|
|
4
4
|
"description": "Helper Functions for Bulltrackers.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
"require-all": "^3.0.0",
|
|
47
47
|
"sharedsetup": "latest",
|
|
48
48
|
"zod": "^4.3.5",
|
|
49
|
-
"@google-cloud/storage": "^7.18.0"
|
|
49
|
+
"@google-cloud/storage": "^7.18.0",
|
|
50
|
+
"@google-cloud/bigquery": "^7.3.0"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
53
|
"bulltracker-deployer": "file:../bulltracker-deployer"
|