bulltrackers-module 1.0.441 → 1.0.442
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.
|
@@ -295,10 +295,39 @@ async function getPiFetchStatus(req, res, dependencies, config) {
|
|
|
295
295
|
|
|
296
296
|
const doc = await docRef.get();
|
|
297
297
|
if (doc.exists) {
|
|
298
|
-
const
|
|
299
|
-
|
|
298
|
+
const docData = doc.data();
|
|
299
|
+
let mergedData = null;
|
|
300
300
|
|
|
301
|
-
if
|
|
301
|
+
// Check if data is sharded
|
|
302
|
+
if (docData._sharded === true && docData._shardCount) {
|
|
303
|
+
// Data is stored in shards - read all shards and merge
|
|
304
|
+
const shardsCol = docRef.collection('_shards');
|
|
305
|
+
const shardsSnapshot = await shardsCol.get();
|
|
306
|
+
|
|
307
|
+
if (!shardsSnapshot.empty) {
|
|
308
|
+
mergedData = {};
|
|
309
|
+
for (const shardDoc of shardsSnapshot.docs) {
|
|
310
|
+
const shardData = shardDoc.data();
|
|
311
|
+
Object.assign(mergedData, shardData);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
} else {
|
|
315
|
+
// Data is in the main document (compressed or not)
|
|
316
|
+
const { tryDecompress } = require('./data_helpers');
|
|
317
|
+
mergedData = tryDecompress(docData);
|
|
318
|
+
|
|
319
|
+
// Handle string decompression result
|
|
320
|
+
if (typeof mergedData === 'string') {
|
|
321
|
+
try {
|
|
322
|
+
mergedData = JSON.parse(mergedData);
|
|
323
|
+
} catch (e) {
|
|
324
|
+
logger.log('WARN', `[getPiFetchStatus] Failed to parse decompressed string for date ${dateStrFormatted}:`, e.message);
|
|
325
|
+
mergedData = null;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (mergedData && typeof mergedData === 'object' && mergedData[String(piCidNum)]) {
|
|
302
331
|
// Computation completed! Update status
|
|
303
332
|
status = 'completed';
|
|
304
333
|
await requestsSnapshot.docs[0].ref.update({
|