bulltrackers-module 1.0.573 → 1.0.574
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.
|
@@ -212,14 +212,14 @@ async function findSubscriptionsForPI(db, logger, piCid, alertTypeId, computatio
|
|
|
212
212
|
return subscriptions;
|
|
213
213
|
}
|
|
214
214
|
} else {
|
|
215
|
-
logger.log('WARN', `[findSubscriptionsForPI] WatchlistMembershipData/${computationDate} not found,
|
|
216
|
-
//
|
|
217
|
-
return
|
|
215
|
+
logger.log('WARN', `[findSubscriptionsForPI] WatchlistMembershipData/${computationDate} not found, returning existing subscriptions (dev overrides only)`);
|
|
216
|
+
// Return subscriptions array which may contain dev overrides
|
|
217
|
+
return subscriptions;
|
|
218
218
|
}
|
|
219
219
|
} catch (error) {
|
|
220
220
|
logger.log('ERROR', `[findSubscriptionsForPI] Error loading WatchlistMembershipData: ${error.message}`);
|
|
221
|
-
//
|
|
222
|
-
return
|
|
221
|
+
// Return subscriptions array which may contain dev overrides
|
|
222
|
+
return subscriptions;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
// Step 2: For each user, read their watchlists from SignedInUsers/{cid}/watchlists
|
|
@@ -298,51 +298,6 @@ async function findSubscriptionsForPI(db, logger, piCid, alertTypeId, computatio
|
|
|
298
298
|
return subscriptions;
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
/**
|
|
302
|
-
* Legacy fallback method - scans all watchlists (used if WatchlistMembershipData is not available)
|
|
303
|
-
*/
|
|
304
|
-
async function findSubscriptionsForPILegacy(db, logger, piCid, alertTypeId, configKey) {
|
|
305
|
-
const subscriptions = [];
|
|
306
|
-
|
|
307
|
-
logger.log('INFO', `[findSubscriptionsForPILegacy] Using legacy method to find subscriptions for PI ${piCid}`);
|
|
308
|
-
|
|
309
|
-
// Get all watchlists from legacy path
|
|
310
|
-
const watchlistsCollection = db.collection('watchlists');
|
|
311
|
-
const watchlistsSnapshot = await watchlistsCollection.get();
|
|
312
|
-
|
|
313
|
-
for (const userDoc of watchlistsSnapshot.docs) {
|
|
314
|
-
const userCid = Number(userDoc.id);
|
|
315
|
-
const userListsSnapshot = await userDoc.ref.collection('lists').get();
|
|
316
|
-
|
|
317
|
-
for (const listDoc of userListsSnapshot.docs) {
|
|
318
|
-
const listData = listDoc.data();
|
|
319
|
-
|
|
320
|
-
// Check static watchlists
|
|
321
|
-
if (listData.type === 'static' && listData.items && Array.isArray(listData.items)) {
|
|
322
|
-
for (const item of listData.items) {
|
|
323
|
-
if (Number(item.cid) === Number(piCid)) {
|
|
324
|
-
const isTestProbe = alertTypeId === 'TestSystemProbe';
|
|
325
|
-
const isEnabled = item.alertConfig && item.alertConfig[configKey] === true;
|
|
326
|
-
|
|
327
|
-
if (isTestProbe || isEnabled) {
|
|
328
|
-
subscriptions.push({
|
|
329
|
-
userCid: userCid,
|
|
330
|
-
piCid: piCid,
|
|
331
|
-
piUsername: item.username || `PI-${piCid}`,
|
|
332
|
-
watchlistId: listDoc.id,
|
|
333
|
-
watchlistName: listData.name || 'Unnamed Watchlist',
|
|
334
|
-
alertConfig: item.alertConfig
|
|
335
|
-
});
|
|
336
|
-
break;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
return subscriptions;
|
|
345
|
-
}
|
|
346
301
|
|
|
347
302
|
/**
|
|
348
303
|
* Check if alert should trigger based on thresholds
|