bulltrackers-module 1.0.571 → 1.0.573
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.
|
@@ -250,6 +250,7 @@ function buildManifest(productLinesToRun = [], calculations) {
|
|
|
250
250
|
category: folderName === 'core' && metadata.category ? metadata.category : folderName,
|
|
251
251
|
sourcePackage: folderName,
|
|
252
252
|
type: metadata.type,
|
|
253
|
+
isPage: metadata.isPage === true,
|
|
253
254
|
isHistorical: metadata.isHistorical !== undefined ? metadata.isHistorical : false,
|
|
254
255
|
rootDataDependencies: metadata.rootDataDependencies || [],
|
|
255
256
|
canHaveMissingRoots: metadata.canHaveMissingRoots || false,
|
|
@@ -162,25 +162,63 @@ async function getUserComputations(req, res, dependencies, config) {
|
|
|
162
162
|
let datesToCheck = [today];
|
|
163
163
|
|
|
164
164
|
if (mode === 'latest') {
|
|
165
|
+
// Use same logic as data-status: search backwards and verify user exists
|
|
166
|
+
// This ensures we find the same date that data-status found
|
|
165
167
|
const firstCompName = computationNames[0];
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
insightsCollection,
|
|
169
|
-
resultsSub,
|
|
170
|
-
compsSub,
|
|
171
|
-
category,
|
|
172
|
-
firstCompName,
|
|
173
|
-
effectiveCid,
|
|
174
|
-
7
|
|
175
|
-
);
|
|
168
|
+
const maxDaysBack = 30; // Match data-status search window
|
|
169
|
+
let foundDate = null;
|
|
176
170
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
171
|
+
for (let daysBack = 0; daysBack < maxDaysBack; daysBack++) {
|
|
172
|
+
const checkDate = new Date();
|
|
173
|
+
checkDate.setDate(checkDate.getDate() - daysBack);
|
|
174
|
+
const dateStr = checkDate.toISOString().split('T')[0];
|
|
175
|
+
|
|
176
|
+
try {
|
|
177
|
+
// Check if computation document exists for this date
|
|
178
|
+
const computationRef = db.collection(insightsCollection)
|
|
179
|
+
.doc(dateStr)
|
|
180
|
+
.collection(resultsSub)
|
|
181
|
+
.doc(category)
|
|
182
|
+
.collection(compsSub)
|
|
183
|
+
.doc(firstCompName);
|
|
184
|
+
|
|
185
|
+
const computationDoc = await computationRef.get();
|
|
186
|
+
|
|
187
|
+
if (computationDoc.exists) {
|
|
188
|
+
// Computation exists, verify user is in it (same as data-status)
|
|
189
|
+
const { found } = await checkPiInComputationDate(
|
|
190
|
+
db,
|
|
191
|
+
insightsCollection,
|
|
192
|
+
resultsSub,
|
|
193
|
+
compsSub,
|
|
194
|
+
category,
|
|
195
|
+
firstCompName,
|
|
196
|
+
dateStr,
|
|
197
|
+
String(effectiveCid),
|
|
198
|
+
logger
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
if (found) {
|
|
202
|
+
foundDate = dateStr;
|
|
203
|
+
if (dateStr !== today) {
|
|
204
|
+
logger.log('INFO', `[getUserComputations] Using fallback date ${foundDate} for effective CID ${effectiveCid} (today: ${today})`);
|
|
205
|
+
} else {
|
|
206
|
+
logger.log('INFO', `[getUserComputations] Found computation for effective CID ${effectiveCid} on today's date`);
|
|
207
|
+
}
|
|
208
|
+
break; // Found user, stop searching
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
} catch (error) {
|
|
212
|
+
// Continue to next date if error
|
|
213
|
+
logger.log('DEBUG', `[getUserComputations] Error checking date ${dateStr}:`, error.message);
|
|
214
|
+
continue;
|
|
181
215
|
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (foundDate) {
|
|
219
|
+
datesToCheck = [foundDate];
|
|
182
220
|
} else {
|
|
183
|
-
logger.log('WARN', `[getUserComputations] No computation data found for CID ${effectiveCid} in last
|
|
221
|
+
logger.log('WARN', `[getUserComputations] No computation data found for CID ${effectiveCid} in last ${maxDaysBack} days. Frontend will use fallback.`);
|
|
184
222
|
return res.status(200).json({
|
|
185
223
|
status: 'success',
|
|
186
224
|
userCid: String(effectiveCid),
|