bulltrackers-module 1.0.729 → 1.0.730

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.
@@ -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 data = await queryPortfolioData(dateStr, null, types, logger);
462
+ const rawData = await queryPortfolioData(dateStr, null, types, logger);
463
463
 
464
- if (data && Object.keys(data).length > 0) {
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 data = await queryHistoryData(dateStr, null, types, logger);
542
+ const rawData = await queryHistoryData(dateStr, null, types, logger);
530
543
 
531
- if (data && Object.keys(data).length > 0) {
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.729",
3
+ "version": "1.0.730",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [