bulltrackers-module 1.0.105 → 1.0.107
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/README.MD +222 -222
- package/functions/appscript-api/helpers/errors.js +19 -19
- package/functions/appscript-api/index.js +58 -58
- package/functions/computation-system/helpers/orchestration_helpers.js +667 -113
- package/functions/computation-system/utils/data_loader.js +191 -191
- package/functions/computation-system/utils/utils.js +149 -254
- package/functions/core/utils/firestore_utils.js +433 -433
- package/functions/core/utils/pubsub_utils.js +53 -53
- package/functions/dispatcher/helpers/dispatch_helpers.js +47 -47
- package/functions/dispatcher/index.js +52 -52
- package/functions/etoro-price-fetcher/helpers/handler_helpers.js +124 -124
- package/functions/fetch-insights/helpers/handler_helpers.js +91 -91
- package/functions/generic-api/helpers/api_helpers.js +379 -379
- package/functions/generic-api/index.js +150 -150
- package/functions/invalid-speculator-handler/helpers/handler_helpers.js +75 -75
- package/functions/orchestrator/helpers/discovery_helpers.js +226 -226
- package/functions/orchestrator/helpers/update_helpers.js +92 -92
- package/functions/orchestrator/index.js +147 -147
- package/functions/price-backfill/helpers/handler_helpers.js +116 -123
- package/functions/social-orchestrator/helpers/orchestrator_helpers.js +61 -61
- package/functions/social-task-handler/helpers/handler_helpers.js +288 -288
- package/functions/task-engine/handler_creator.js +78 -78
- package/functions/task-engine/helpers/discover_helpers.js +125 -125
- package/functions/task-engine/helpers/update_helpers.js +118 -118
- package/functions/task-engine/helpers/verify_helpers.js +162 -162
- package/functions/task-engine/utils/firestore_batch_manager.js +258 -258
- package/index.js +105 -113
- package/package.json +45 -45
- package/functions/computation-system/computation_dependencies.json +0 -120
- package/functions/computation-system/helpers/worker_helpers.js +0 -340
- package/functions/computation-system/utils/computation_state_manager.js +0 -178
- package/functions/computation-system/utils/dependency_graph.js +0 -191
- package/functions/speculator-cleanup-orchestrator/helpers/cleanup_helpers.js +0 -160
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Main pipe: pipe.maintenance.runSocialOrchestrator
|
|
3
|
-
* This function is triggered by a schedule. It fans out the work by
|
|
4
|
-
* publishing one Pub/Sub message for each target ticker.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Main pipe (Orchestrator): pipe.maintenance.runSocialOrchestrator
|
|
9
|
-
* @param {object} config - Configuration object.
|
|
10
|
-
* @param {object} dependencies - Contains db, logger, firestoreUtils, pubsubUtils.
|
|
11
|
-
* @returns {Promise<object>} Summary of the orchestration.
|
|
12
|
-
*/
|
|
13
|
-
exports.runSocialOrchestrator = async (config, dependencies) => {
|
|
14
|
-
const { logger, pubsubUtils } = dependencies;
|
|
15
|
-
logger.log('INFO', '[SocialOrchestrator] Starting social post fetching orchestration...');
|
|
16
|
-
|
|
17
|
-
// Validate configuration
|
|
18
|
-
if (!config.targetTickerIds || !Array.isArray(config.targetTickerIds) || !config.socialFetchTaskTopicName || !config.socialFetchTimeWindowHours) {
|
|
19
|
-
logger.log('ERROR', '[SocialOrchestrator] Missing required configuration: targetTickerIds (array), socialFetchTaskTopicName, or socialFetchTimeWindowHours.');
|
|
20
|
-
throw new Error('Missing required configuration for Social Orchestrator.');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
const tasks = [];
|
|
25
|
-
const { targetTickerIds, socialFetchTimeWindowHours } = config;
|
|
26
|
-
|
|
27
|
-
// Calculate the 'since' timestamp
|
|
28
|
-
const sinceTimestamp = new Date();
|
|
29
|
-
sinceTimestamp.setHours(sinceTimestamp.getHours() - socialFetchTimeWindowHours);
|
|
30
|
-
|
|
31
|
-
// Add a 15-minute buffer to ensure overlap
|
|
32
|
-
sinceTimestamp.setMinutes(sinceTimestamp.getMinutes() - 15);
|
|
33
|
-
|
|
34
|
-
const sinceISO = sinceTimestamp.toISOString();
|
|
35
|
-
|
|
36
|
-
for (const tickerId of targetTickerIds) {
|
|
37
|
-
tasks.push({
|
|
38
|
-
tickerId: String(tickerId), // Ensure it's a string
|
|
39
|
-
since: sinceISO
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (tasks.length === 0) {
|
|
44
|
-
logger.log('WARN', '[SocialOrchestrator] No target tickers found to process.');
|
|
45
|
-
return { success: true, message: "No target tickers configured." };
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Use pubsubUtils to batch publish all ticker tasks
|
|
49
|
-
await pubsubUtils.batchPublishTasks(dependencies, {
|
|
50
|
-
topicName: config.socialFetchTaskTopicName,
|
|
51
|
-
tasks: tasks,
|
|
52
|
-
taskType: 'social-fetch-task'
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
logger.log('SUCCESS', `[SocialOrchestrator] Successfully published ${tasks.length} social fetch tasks for window >= ${sinceISO}.`);
|
|
56
|
-
return { success: true, tasksQueued: tasks.length };
|
|
57
|
-
|
|
58
|
-
} catch (error) {
|
|
59
|
-
logger.log('ERROR', '[SocialOrchestrator] Fatal error during orchestration.', { errorMessage: error.message, errorStack: error.stack });
|
|
60
|
-
throw error;
|
|
61
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Main pipe: pipe.maintenance.runSocialOrchestrator
|
|
3
|
+
* This function is triggered by a schedule. It fans out the work by
|
|
4
|
+
* publishing one Pub/Sub message for each target ticker.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Main pipe (Orchestrator): pipe.maintenance.runSocialOrchestrator
|
|
9
|
+
* @param {object} config - Configuration object.
|
|
10
|
+
* @param {object} dependencies - Contains db, logger, firestoreUtils, pubsubUtils.
|
|
11
|
+
* @returns {Promise<object>} Summary of the orchestration.
|
|
12
|
+
*/
|
|
13
|
+
exports.runSocialOrchestrator = async (config, dependencies) => {
|
|
14
|
+
const { logger, pubsubUtils } = dependencies;
|
|
15
|
+
logger.log('INFO', '[SocialOrchestrator] Starting social post fetching orchestration...');
|
|
16
|
+
|
|
17
|
+
// Validate configuration
|
|
18
|
+
if (!config.targetTickerIds || !Array.isArray(config.targetTickerIds) || !config.socialFetchTaskTopicName || !config.socialFetchTimeWindowHours) {
|
|
19
|
+
logger.log('ERROR', '[SocialOrchestrator] Missing required configuration: targetTickerIds (array), socialFetchTaskTopicName, or socialFetchTimeWindowHours.');
|
|
20
|
+
throw new Error('Missing required configuration for Social Orchestrator.');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
const tasks = [];
|
|
25
|
+
const { targetTickerIds, socialFetchTimeWindowHours } = config;
|
|
26
|
+
|
|
27
|
+
// Calculate the 'since' timestamp
|
|
28
|
+
const sinceTimestamp = new Date();
|
|
29
|
+
sinceTimestamp.setHours(sinceTimestamp.getHours() - socialFetchTimeWindowHours);
|
|
30
|
+
|
|
31
|
+
// Add a 15-minute buffer to ensure overlap
|
|
32
|
+
sinceTimestamp.setMinutes(sinceTimestamp.getMinutes() - 15);
|
|
33
|
+
|
|
34
|
+
const sinceISO = sinceTimestamp.toISOString();
|
|
35
|
+
|
|
36
|
+
for (const tickerId of targetTickerIds) {
|
|
37
|
+
tasks.push({
|
|
38
|
+
tickerId: String(tickerId), // Ensure it's a string
|
|
39
|
+
since: sinceISO
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (tasks.length === 0) {
|
|
44
|
+
logger.log('WARN', '[SocialOrchestrator] No target tickers found to process.');
|
|
45
|
+
return { success: true, message: "No target tickers configured." };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Use pubsubUtils to batch publish all ticker tasks
|
|
49
|
+
await pubsubUtils.batchPublishTasks(dependencies, {
|
|
50
|
+
topicName: config.socialFetchTaskTopicName,
|
|
51
|
+
tasks: tasks,
|
|
52
|
+
taskType: 'social-fetch-task'
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
logger.log('SUCCESS', `[SocialOrchestrator] Successfully published ${tasks.length} social fetch tasks for window >= ${sinceISO}.`);
|
|
56
|
+
return { success: true, tasksQueued: tasks.length };
|
|
57
|
+
|
|
58
|
+
} catch (error) {
|
|
59
|
+
logger.log('ERROR', '[SocialOrchestrator] Fatal error during orchestration.', { errorMessage: error.message, errorStack: error.stack });
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
62
|
};
|