aiden-shared-calculations-unified 1.0.40 → 1.0.42
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.
|
@@ -67,7 +67,7 @@ class SmartMoneyFlow {
|
|
|
67
67
|
let profitableUsersFound = 0;
|
|
68
68
|
shardSnapshots.forEach((snap, index) => {
|
|
69
69
|
if (snap.exists) {
|
|
70
|
-
const shardData = snap.data()
|
|
70
|
+
const shardData = snap.data() || {};
|
|
71
71
|
for (const userId in shardData) {
|
|
72
72
|
const history = shardData[userId];
|
|
73
73
|
// Check if history is an array and has enough entries
|
|
@@ -11,8 +11,7 @@ const { Firestore } = require('@google-cloud/firestore');
|
|
|
11
11
|
const firestore = new Firestore();
|
|
12
12
|
const { loadAllPriceData, getDailyPriceChange } = require('../../../utils/price_data_provider');
|
|
13
13
|
const { loadInstrumentMappings, getInstrumentSectorMap } = require('../../../utils/sector_mapping_provider');
|
|
14
|
-
const { loadDataByRefs } = require('../../../../bulltrackers-module/functions/computation-system/utils/data_loader'); // Adjust path as needed
|
|
15
|
-
|
|
14
|
+
const { loadDataByRefs, getPortfolioPartRefs } = require('../../../../bulltrackers-module/functions/computation-system/utils/data_loader'); // Adjust path as needed
|
|
16
15
|
// Config
|
|
17
16
|
const NUM_SHARDS = 50; // Must match the number of shards to read/write
|
|
18
17
|
const ROLLING_DAYS = 90;
|
|
@@ -242,7 +241,7 @@ class UserInvestmentProfile {
|
|
|
242
241
|
const yesterdayDate = new Date(dateStr + 'T00:00:00Z');
|
|
243
242
|
yesterdayDate.setUTCDate(yesterdayDate.getUTCDate() - 1);
|
|
244
243
|
const yesterdayStr = yesterdayDate.toISOString().slice(0, 10);
|
|
245
|
-
const yesterdayRefs = await
|
|
244
|
+
const yesterdayRefs = await getPortfolioPartRefs(config, dependencies, yesterdayStr);
|
|
246
245
|
const yesterdayPortfolios = await loadFullDayMap(config, dependencies, yesterdayRefs);
|
|
247
246
|
logger.log('INFO', `[UserInvestmentProfile] Loaded ${yesterdayRefs.length} part refs for yesterday.`);
|
|
248
247
|
|
|
@@ -82,7 +82,7 @@ class UserProfitabilityTracker {
|
|
|
82
82
|
shardPromises.push(docRef.get());
|
|
83
83
|
}
|
|
84
84
|
const shardSnapshots = await Promise.all(shardPromises);
|
|
85
|
-
const existingData = shardSnapshots.map(snap => (snap.exists ? snap.data()
|
|
85
|
+
const existingData = shardSnapshots.map(snap => (snap.exists ? snap.data() : {}) || {});
|
|
86
86
|
|
|
87
87
|
|
|
88
88
|
for (const userId in this.dailyData) {
|