bulltrackers-module 1.0.412 → 1.0.414
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.
|
@@ -66,9 +66,12 @@ async function findLatestPortfolioDate(db, signedInUsersCollection, userCid, max
|
|
|
66
66
|
* Helper function to find the latest available date for computation results
|
|
67
67
|
* Searches backwards from today up to 30 days
|
|
68
68
|
*/
|
|
69
|
-
async function findLatestComputationDate(db, insightsCollection, category, computationName, userCid, maxDaysBack = 30) {
|
|
69
|
+
async function findLatestComputationDate(db, insightsCollection, resultsSub, compsSub, category, computationName, userCid, maxDaysBack = 30) {
|
|
70
70
|
const today = new Date();
|
|
71
71
|
|
|
72
|
+
// Log the path structure being checked
|
|
73
|
+
console.log(`[findLatestComputationDate] Searching for: ${insightsCollection}/{date}/${resultsSub}/${category}/${compsSub}/${computationName}`);
|
|
74
|
+
|
|
72
75
|
for (let i = 0; i < maxDaysBack; i++) {
|
|
73
76
|
const checkDate = new Date(today);
|
|
74
77
|
checkDate.setDate(checkDate.getDate() - i);
|
|
@@ -77,24 +80,33 @@ async function findLatestComputationDate(db, insightsCollection, category, compu
|
|
|
77
80
|
try {
|
|
78
81
|
const computationRef = db.collection(insightsCollection)
|
|
79
82
|
.doc(dateStr)
|
|
80
|
-
.collection(
|
|
83
|
+
.collection(resultsSub)
|
|
81
84
|
.doc(category)
|
|
82
|
-
.collection(
|
|
85
|
+
.collection(compsSub)
|
|
83
86
|
.doc(computationName);
|
|
84
87
|
|
|
85
88
|
const computationDoc = await computationRef.get();
|
|
86
89
|
|
|
90
|
+
// Log each date being checked
|
|
91
|
+
if (i < 3) { // Only log first 3 to avoid spam
|
|
92
|
+
console.log(`[findLatestComputationDate] Checking date ${dateStr}: exists=${computationDoc.exists}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
87
95
|
// Just check if document exists - don't check for CID here
|
|
88
96
|
// We'll check for CID in the calling function after decompression
|
|
89
97
|
if (computationDoc.exists) {
|
|
98
|
+
console.log(`[findLatestComputationDate] Found document at date: ${dateStr}`);
|
|
90
99
|
return dateStr; // Found document for this date
|
|
91
100
|
}
|
|
92
101
|
} catch (error) {
|
|
102
|
+
// Log errors for debugging
|
|
103
|
+
console.error(`[findLatestComputationDate] Error checking date ${dateStr}:`, error.message);
|
|
93
104
|
// Continue to next date if error
|
|
94
105
|
continue;
|
|
95
106
|
}
|
|
96
107
|
}
|
|
97
108
|
|
|
109
|
+
console.log(`[findLatestComputationDate] No document found in last ${maxDaysBack} days`);
|
|
98
110
|
return null; // No document found in the last maxDaysBack days
|
|
99
111
|
}
|
|
100
112
|
|
|
@@ -661,7 +673,9 @@ async function getUserComputations(req, res, dependencies, config) {
|
|
|
661
673
|
const firstCompName = computationNames[0];
|
|
662
674
|
const latestDate = await findLatestComputationDate(
|
|
663
675
|
db,
|
|
664
|
-
insightsCollection,
|
|
676
|
+
insightsCollection,
|
|
677
|
+
resultsSub,
|
|
678
|
+
compsSub,
|
|
665
679
|
category,
|
|
666
680
|
firstCompName,
|
|
667
681
|
userCid,
|
|
@@ -785,9 +799,13 @@ async function autoGenerateWatchlist(req, res, dependencies, config) {
|
|
|
785
799
|
const computationName = 'SignedInUserCopiedPIs';
|
|
786
800
|
|
|
787
801
|
// Try to find latest computation date (with fallback)
|
|
802
|
+
const resultsSub = config.resultsSubcollection || 'results';
|
|
803
|
+
const compsSub = config.computationsSubcollection || 'computations';
|
|
788
804
|
const computationDate = await findLatestComputationDate(
|
|
789
805
|
db,
|
|
790
|
-
insightsCollection,
|
|
806
|
+
insightsCollection,
|
|
807
|
+
resultsSub,
|
|
808
|
+
compsSub,
|
|
791
809
|
category,
|
|
792
810
|
computationName,
|
|
793
811
|
userCid,
|
|
@@ -1381,7 +1399,9 @@ async function getPiProfile(req, res, dependencies, config) {
|
|
|
1381
1399
|
// Find latest available computation date (just check if document exists, not CID)
|
|
1382
1400
|
const latestDate = await findLatestComputationDate(
|
|
1383
1401
|
db,
|
|
1384
|
-
insightsCollection,
|
|
1402
|
+
insightsCollection,
|
|
1403
|
+
resultsSub,
|
|
1404
|
+
compsSub,
|
|
1385
1405
|
category,
|
|
1386
1406
|
computationName,
|
|
1387
1407
|
null, // Don't pass CID - just find if document exists
|