bulltrackers-module 1.0.729 → 1.0.731
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.
|
@@ -207,8 +207,9 @@ class StandardExecutor {
|
|
|
207
207
|
|
|
208
208
|
let social = null;
|
|
209
209
|
if (globalRoots.social) {
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
// Use optional chaining to handle missing sub-objects (pi, signedIn, generic)
|
|
211
|
+
social = (actualType === 'POPULAR_INVESTOR' ? globalRoots.social.pi?.[userId] :
|
|
212
|
+
(actualType === 'SIGNED_IN_USER' ? globalRoots.social.signedIn?.[userId] : globalRoots.social.generic)) || {};
|
|
212
213
|
}
|
|
213
214
|
|
|
214
215
|
// 4. Build Context
|
|
@@ -459,9 +459,22 @@ exports.streamPortfolioData = async function* (config, deps, dateStr, refs, user
|
|
|
459
459
|
if (isBigQuery && process.env.BIGQUERY_ENABLED !== 'false') {
|
|
460
460
|
try {
|
|
461
461
|
const types = userTypes || ['POPULAR_INVESTOR', 'SIGNED_IN_USER'];
|
|
462
|
-
const
|
|
462
|
+
const rawData = await queryPortfolioData(dateStr, null, types, logger);
|
|
463
463
|
|
|
464
|
-
if (
|
|
464
|
+
if (rawData && Object.keys(rawData).length > 0) {
|
|
465
|
+
// Transform BigQuery format to computation system format
|
|
466
|
+
// BigQuery returns: { cid: { portfolio_data: {...}, user_type: '...', fetched_at: '...' } }
|
|
467
|
+
// Computation system expects: { cid: { ...portfolioFields..., _userType: '...' } }
|
|
468
|
+
const data = {};
|
|
469
|
+
for (const [cid, record] of Object.entries(rawData)) {
|
|
470
|
+
// Unwrap portfolio_data and add _userType metadata
|
|
471
|
+
const portfolioData = record.portfolio_data || {};
|
|
472
|
+
data[cid] = {
|
|
473
|
+
...portfolioData,
|
|
474
|
+
_userType: record.user_type
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
|
|
465
478
|
logger.log('INFO', `[DataLoader] ✅ Streaming ${Object.keys(data).length} portfolios from BigQuery (${dateStr})`);
|
|
466
479
|
|
|
467
480
|
// Yield in chunks of 100 users for memory efficiency
|
|
@@ -526,9 +539,22 @@ exports.streamHistoryData = async function* (config, deps, dateStr, refs, userTy
|
|
|
526
539
|
if (isBigQuery && process.env.BIGQUERY_ENABLED !== 'false') {
|
|
527
540
|
try {
|
|
528
541
|
const types = userTypes || ['POPULAR_INVESTOR', 'SIGNED_IN_USER'];
|
|
529
|
-
const
|
|
542
|
+
const rawData = await queryHistoryData(dateStr, null, types, logger);
|
|
530
543
|
|
|
531
|
-
if (
|
|
544
|
+
if (rawData && Object.keys(rawData).length > 0) {
|
|
545
|
+
// Transform BigQuery format to computation system format
|
|
546
|
+
// BigQuery returns: { cid: { history_data: {...}, user_type: '...', fetched_at: '...' } }
|
|
547
|
+
// Computation system expects: { cid: { ...historyFields..., _userType: '...' } }
|
|
548
|
+
const data = {};
|
|
549
|
+
for (const [cid, record] of Object.entries(rawData)) {
|
|
550
|
+
// Unwrap history_data and add _userType metadata
|
|
551
|
+
const historyData = record.history_data || {};
|
|
552
|
+
data[cid] = {
|
|
553
|
+
...historyData,
|
|
554
|
+
_userType: record.user_type
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
|
|
532
558
|
logger.log('INFO', `[DataLoader] ✅ Streaming ${Object.keys(data).length} history records from BigQuery (${dateStr})`);
|
|
533
559
|
|
|
534
560
|
// Yield in chunks of 100 users
|