bulltrackers-module 1.0.740 → 1.0.741
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.
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Admin Test Endpoint for Computation System
|
|
3
|
-
*
|
|
4
|
-
* SECURITY: This endpoint is protected by GCP IAM (requireAuth: true).
|
|
3
|
+
* * SECURITY: This endpoint is protected by GCP IAM (requireAuth: true).
|
|
5
4
|
* Only service accounts and users with cloudfunctions.invoker can access it.
|
|
6
|
-
*
|
|
7
|
-
* PURPOSE:
|
|
5
|
+
* * PURPOSE:
|
|
8
6
|
* - Test computations in production without waiting for schedule
|
|
9
7
|
* - Force re-runs of computations (bypass hash checks)
|
|
10
8
|
* - Test worker pool functionality
|
|
11
9
|
* - Run on specific entities for debugging
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* -d '{"action": "run", "computation": "UserPortfolioSummary", "date": "2026-01-25"}'
|
|
10
|
+
* * USAGE:
|
|
11
|
+
* curl -X POST https://REGION-PROJECT.cloudfunctions.net/compute-admin-test \
|
|
12
|
+
* -H "Authorization: Bearer $(gcloud auth print-identity-token)" \
|
|
13
|
+
* -H "Content-Type: application/json" \
|
|
14
|
+
* -d '{"action": "run", "computation": "UserPortfolioSummary", "date": "2026-01-25"}'
|
|
18
15
|
*/
|
|
19
16
|
|
|
20
17
|
const system = require('../core-api');
|
|
18
|
+
|
|
21
19
|
/**
|
|
22
20
|
* Admin test handler.
|
|
23
21
|
*/
|
|
@@ -103,15 +101,31 @@ async function adminTestHandler(req, res) {
|
|
|
103
101
|
console.log(`[AdminTest] Running ${computation} for ${date}...`);
|
|
104
102
|
console.log(`[AdminTest] Options: force=${force}, dryRun=${dryRun}, entityIds=${entityIds?.join(',') || 'all'}`);
|
|
105
103
|
|
|
106
|
-
|
|
104
|
+
// Prepare run options
|
|
105
|
+
const runOptions = {
|
|
107
106
|
date,
|
|
108
107
|
computation,
|
|
109
108
|
entityIds: entityIds || null,
|
|
110
109
|
dryRun,
|
|
111
110
|
force,
|
|
112
|
-
// Pass worker pool override explicitly (avoids env var caching issues)
|
|
113
111
|
useWorkerPool
|
|
114
|
-
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// [FIX] If forcing worker pool, inject config to enable it dynamically
|
|
115
|
+
// This prevents Orchestrator from ignoring the request if default config has enabled: false
|
|
116
|
+
if (useWorkerPool) {
|
|
117
|
+
const baseConfig = system.config;
|
|
118
|
+
runOptions.config = {
|
|
119
|
+
...baseConfig,
|
|
120
|
+
workerPool: {
|
|
121
|
+
...(baseConfig.workerPool || {}),
|
|
122
|
+
enabled: true
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
console.log('[AdminTest] Injecting config to FORCE enable RemoteTaskRunner');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const result = await system.runComputation(runOptions);
|
|
115
129
|
|
|
116
130
|
const duration = Date.now() - startTime;
|
|
117
131
|
|
|
@@ -155,14 +169,28 @@ async function adminTestHandler(req, res) {
|
|
|
155
169
|
|
|
156
170
|
console.log(`[AdminTest] Running LIMITED test: ${sampleEntities.length} entities`);
|
|
157
171
|
|
|
158
|
-
const
|
|
172
|
+
const runOptions = {
|
|
159
173
|
date,
|
|
160
174
|
computation,
|
|
161
175
|
entityIds: sampleEntities,
|
|
162
176
|
dryRun,
|
|
163
177
|
force,
|
|
164
|
-
useWorkerPool
|
|
165
|
-
}
|
|
178
|
+
useWorkerPool
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// Apply the same fix for run_limited if needed
|
|
182
|
+
if (useWorkerPool) {
|
|
183
|
+
const baseConfig = system.config;
|
|
184
|
+
runOptions.config = {
|
|
185
|
+
...baseConfig,
|
|
186
|
+
workerPool: {
|
|
187
|
+
...(baseConfig.workerPool || {}),
|
|
188
|
+
enabled: true
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const result = await system.runComputation(runOptions);
|
|
166
194
|
|
|
167
195
|
const duration = Date.now() - startTime;
|
|
168
196
|
|
|
@@ -323,4 +351,4 @@ async function getSampleEntities(computation, date, limit) {
|
|
|
323
351
|
}
|
|
324
352
|
}
|
|
325
353
|
|
|
326
|
-
module.exports = { adminTestHandler };
|
|
354
|
+
module.exports = { adminTestHandler };
|