bulltrackers-module 1.0.491 → 1.0.492
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.
|
@@ -891,6 +891,7 @@ async function getUserComputations(req, res, dependencies, config) {
|
|
|
891
891
|
|
|
892
892
|
// If mode is 'latest', try to find the latest available date for the first computation
|
|
893
893
|
// Use effectiveCid for computation lookup
|
|
894
|
+
// CRITICAL: Only look back 7 days as per requirements
|
|
894
895
|
if (mode === 'latest') {
|
|
895
896
|
const firstCompName = computationNames[0];
|
|
896
897
|
const latestDate = await findLatestComputationDate(
|
|
@@ -901,7 +902,7 @@ async function getUserComputations(req, res, dependencies, config) {
|
|
|
901
902
|
category,
|
|
902
903
|
firstCompName,
|
|
903
904
|
effectiveCid,
|
|
904
|
-
|
|
905
|
+
7 // Only look back 7 days as per requirements
|
|
905
906
|
);
|
|
906
907
|
|
|
907
908
|
if (latestDate) {
|
|
@@ -910,14 +911,15 @@ async function getUserComputations(req, res, dependencies, config) {
|
|
|
910
911
|
logger.log('INFO', `[getUserComputations] Using fallback date ${latestDate} for effective CID ${effectiveCid} (today: ${today})`);
|
|
911
912
|
}
|
|
912
913
|
} else {
|
|
913
|
-
// No data found
|
|
914
|
+
// No data found after 7 days - return empty (frontend will use fallback)
|
|
915
|
+
logger.log('WARN', `[getUserComputations] No computation data found for CID ${effectiveCid} in last 7 days. Frontend will use fallback.`);
|
|
914
916
|
return res.status(200).json({
|
|
915
917
|
status: 'success',
|
|
916
918
|
userCid: String(effectiveCid),
|
|
917
919
|
mode,
|
|
918
920
|
computations: computationNames,
|
|
919
921
|
data: {},
|
|
920
|
-
isFallback:
|
|
922
|
+
isFallback: true, // Mark as fallback since no data found
|
|
921
923
|
requestedDate: today,
|
|
922
924
|
isImpersonating: isImpersonating || false,
|
|
923
925
|
actualCid: Number(userCid)
|
|
@@ -955,10 +957,38 @@ async function getUserComputations(req, res, dependencies, config) {
|
|
|
955
957
|
if (doc.exists) {
|
|
956
958
|
// Decompress if needed (handles byte string storage)
|
|
957
959
|
const rawData = doc.data();
|
|
958
|
-
|
|
960
|
+
let data = tryDecompress(rawData);
|
|
961
|
+
|
|
962
|
+
// Handle string decompression result
|
|
963
|
+
if (typeof data === 'string') {
|
|
964
|
+
try {
|
|
965
|
+
data = JSON.parse(data);
|
|
966
|
+
} catch (e) {
|
|
967
|
+
logger.log('WARN', `[getUserComputations] Failed to parse decompressed string for ${compName} on ${date}:`, e.message);
|
|
968
|
+
data = null;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
// Check if data is sharded
|
|
973
|
+
if (data && data._sharded === true && data._shardCount) {
|
|
974
|
+
// Data is stored in shards - read all shards and merge
|
|
975
|
+
const shardsCol = docRef.collection('_shards');
|
|
976
|
+
const shardsSnapshot = await shardsCol.get();
|
|
977
|
+
|
|
978
|
+
if (!shardsSnapshot.empty) {
|
|
979
|
+
data = {};
|
|
980
|
+
for (const shardDoc of shardsSnapshot.docs) {
|
|
981
|
+
const shardData = shardDoc.data();
|
|
982
|
+
Object.assign(data, shardData);
|
|
983
|
+
}
|
|
984
|
+
} else {
|
|
985
|
+
data = null; // Sharded but no shards found
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
|
|
959
989
|
// Filter by user CID - computation results are stored as { cid: result }
|
|
960
990
|
// Use effectiveCid for lookup
|
|
961
|
-
let userResult = data[String(effectiveCid)];
|
|
991
|
+
let userResult = data && typeof data === 'object' ? data[String(effectiveCid)] : null;
|
|
962
992
|
|
|
963
993
|
// Apply dev override for computations that include copied PIs (use actual userCid for override check)
|
|
964
994
|
if (isDevOverrideActive && (compName === 'SignedInUserProfileMetrics' || compName === 'SignedInUserCopiedPIs')) {
|