bulltrackers-module 1.0.410 → 1.0.412
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.
|
@@ -84,14 +84,10 @@ async function findLatestComputationDate(db, insightsCollection, category, compu
|
|
|
84
84
|
|
|
85
85
|
const computationDoc = await computationRef.get();
|
|
86
86
|
|
|
87
|
+
// Just check if document exists - don't check for CID here
|
|
88
|
+
// We'll check for CID in the calling function after decompression
|
|
87
89
|
if (computationDoc.exists) {
|
|
88
|
-
|
|
89
|
-
// Decompress if needed (handles byte string storage)
|
|
90
|
-
const computationData = tryDecompress(rawData);
|
|
91
|
-
// Check if user's CID exists in the computation result
|
|
92
|
-
if (computationData && computationData[String(userCid)]) {
|
|
93
|
-
return dateStr; // Found data for this date
|
|
94
|
-
}
|
|
90
|
+
return dateStr; // Found document for this date
|
|
95
91
|
}
|
|
96
92
|
} catch (error) {
|
|
97
93
|
// Continue to next date if error
|
|
@@ -99,7 +95,7 @@ async function findLatestComputationDate(db, insightsCollection, category, compu
|
|
|
99
95
|
}
|
|
100
96
|
}
|
|
101
97
|
|
|
102
|
-
return null; // No
|
|
98
|
+
return null; // No document found in the last maxDaysBack days
|
|
103
99
|
}
|
|
104
100
|
|
|
105
101
|
/**
|
|
@@ -1380,17 +1376,22 @@ async function getPiProfile(req, res, dependencies, config) {
|
|
|
1380
1376
|
const category = 'popular_investor';
|
|
1381
1377
|
const today = new Date().toISOString().split('T')[0];
|
|
1382
1378
|
|
|
1383
|
-
|
|
1379
|
+
logger.log('INFO', `[getPiProfile] Starting search for PI CID: ${cid}`);
|
|
1380
|
+
|
|
1381
|
+
// Find latest available computation date (just check if document exists, not CID)
|
|
1384
1382
|
const latestDate = await findLatestComputationDate(
|
|
1385
1383
|
db,
|
|
1386
1384
|
insightsCollection,
|
|
1387
1385
|
category,
|
|
1388
1386
|
computationName,
|
|
1389
|
-
|
|
1387
|
+
null, // Don't pass CID - just find if document exists
|
|
1390
1388
|
30
|
|
1391
1389
|
);
|
|
1392
1390
|
|
|
1391
|
+
logger.log('INFO', `[getPiProfile] Latest computation date found: ${latestDate || 'NONE'}`);
|
|
1392
|
+
|
|
1393
1393
|
if (!latestDate) {
|
|
1394
|
+
logger.log('WARN', `[getPiProfile] No computation document found for ${computationName} in last 30 days`);
|
|
1394
1395
|
return res.status(404).json({
|
|
1395
1396
|
error: "Profile data not available",
|
|
1396
1397
|
message: "No computation results found for this Popular Investor"
|
|
@@ -1405,9 +1406,12 @@ async function getPiProfile(req, res, dependencies, config) {
|
|
|
1405
1406
|
.collection(compsSub)
|
|
1406
1407
|
.doc(computationName);
|
|
1407
1408
|
|
|
1409
|
+
logger.log('INFO', `[getPiProfile] Fetching document at path: ${insightsCollection}/${latestDate}/${resultsSub}/${category}/${compsSub}/${computationName}`);
|
|
1410
|
+
|
|
1408
1411
|
const computationDoc = await computationRef.get();
|
|
1409
1412
|
|
|
1410
1413
|
if (!computationDoc.exists) {
|
|
1414
|
+
logger.log('WARN', `[getPiProfile] Document does not exist at expected path`);
|
|
1411
1415
|
return res.status(404).json({
|
|
1412
1416
|
error: "Profile data not found",
|
|
1413
1417
|
message: "Computation document does not exist"
|
|
@@ -1416,16 +1420,51 @@ async function getPiProfile(req, res, dependencies, config) {
|
|
|
1416
1420
|
|
|
1417
1421
|
// Decompress if needed (handles byte string storage)
|
|
1418
1422
|
const rawData = computationDoc.data();
|
|
1423
|
+
const wasCompressed = rawData && rawData._compressed === true;
|
|
1424
|
+
logger.log('INFO', `[getPiProfile] Document exists. Was compressed: ${wasCompressed}, CID being searched: ${cid}`);
|
|
1425
|
+
logger.log('INFO', `[getPiProfile] Raw data keys:`, rawData ? Object.keys(rawData).slice(0, 10) : 'NO DATA');
|
|
1426
|
+
|
|
1419
1427
|
const computationData = tryDecompress(rawData);
|
|
1420
|
-
|
|
1428
|
+
|
|
1429
|
+
// Debug logging: Show full decompressed document structure
|
|
1430
|
+
logger.log('INFO', `[getPiProfile] Decompressed data structure:`, {
|
|
1431
|
+
hasData: !!computationData,
|
|
1432
|
+
dataType: typeof computationData,
|
|
1433
|
+
isArray: Array.isArray(computationData),
|
|
1434
|
+
keys: computationData && typeof computationData === 'object' ? Object.keys(computationData).slice(0, 50) : 'N/A', // First 50 keys
|
|
1435
|
+
totalKeys: computationData && typeof computationData === 'object' ? Object.keys(computationData).length : 0,
|
|
1436
|
+
searchingForCid: String(cid),
|
|
1437
|
+
cidExists: computationData && computationData[String(cid)] !== undefined,
|
|
1438
|
+
sampleCids: computationData && typeof computationData === 'object' ? Object.keys(computationData).slice(0, 10) : []
|
|
1439
|
+
});
|
|
1440
|
+
|
|
1441
|
+
// Log full decompressed data (will be large but needed for debugging)
|
|
1442
|
+
logger.log('INFO', `[getPiProfile] FULL DECOMPRESSED DOCUMENT CONTENTS:`, JSON.stringify(computationData, null, 2));
|
|
1443
|
+
|
|
1444
|
+
const cidStr = String(cid);
|
|
1445
|
+
const profileData = computationData && typeof computationData === 'object' ? computationData[cidStr] : undefined;
|
|
1421
1446
|
|
|
1422
1447
|
if (!profileData) {
|
|
1448
|
+
// Additional debug info in error response
|
|
1449
|
+
const availableCids = computationData && typeof computationData === 'object' ? Object.keys(computationData).slice(0, 20) : [];
|
|
1450
|
+
logger.log('WARN', `[getPiProfile] CID ${cid} (as string: "${cidStr}") not found in computation data. Available CIDs (sample):`, availableCids);
|
|
1451
|
+
|
|
1423
1452
|
return res.status(404).json({
|
|
1424
1453
|
error: "Profile data not found",
|
|
1425
|
-
message: "No data for this Popular Investor in computation results"
|
|
1454
|
+
message: "No data for this Popular Investor in computation results",
|
|
1455
|
+
debug: {
|
|
1456
|
+
searchedCid: cidStr,
|
|
1457
|
+
wasCompressed: wasCompressed,
|
|
1458
|
+
totalKeysInDocument: computationData && typeof computationData === 'object' ? Object.keys(computationData).length : 0,
|
|
1459
|
+
sampleAvailableCids: availableCids,
|
|
1460
|
+
dataDate: latestDate,
|
|
1461
|
+
documentPath: `${insightsCollection}/${latestDate}/${resultsSub}/${category}/${compsSub}/${computationName}`
|
|
1462
|
+
}
|
|
1426
1463
|
});
|
|
1427
1464
|
}
|
|
1428
1465
|
|
|
1466
|
+
logger.log('SUCCESS', `[getPiProfile] Found profile data for CID ${cid} from date ${latestDate}`);
|
|
1467
|
+
|
|
1429
1468
|
return res.status(200).json({
|
|
1430
1469
|
status: 'success',
|
|
1431
1470
|
cid: String(cid),
|