bulltrackers-module 1.0.469 → 1.0.470

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.
@@ -237,10 +237,14 @@ exports.runRootDataIndexer = async (config, dependencies) => {
237
237
 
238
238
  // 4. Universal Social Check via Collection Group
239
239
  // Path: Collection Group 'posts' where 'fetchedAt' is within the day
240
+ // This queries ALL 'posts' subcollections across:
241
+ // - signed_in_users_social/{userId}/posts/{postId}
242
+ // - pi_social_posts/{userId}/posts/{postId}
243
+ // - daily_social_insights/{date}/posts/{postId}
240
244
  const universalSocialQuery = db.collectionGroup('posts')
241
245
  .where('fetchedAt', '>=', dayStart)
242
246
  .where('fetchedAt', '<=', dayEnd)
243
- .limit(50);
247
+ .limit(100); // Increased limit to ensure we catch all posts
244
248
 
245
249
  // --- Execute Checks ---
246
250
  const [
@@ -275,34 +279,64 @@ exports.runRootDataIndexer = async (config, dependencies) => {
275
279
  let foundPISocial = false;
276
280
  let foundSignedInSocial = false;
277
281
 
282
+ logger.log('INFO', `[RootDataIndexer/${dateStr}] Checking social data availability (dayStart: ${dayStart.toISOString()}, dayEnd: ${dayEnd.toISOString()})`);
283
+ logger.log('INFO', `[RootDataIndexer/${dateStr}] Looking for PI social in: "${PI_SOCIAL_COLL_NAME}", Signed-in social in: "${SIGNED_IN_SOCIAL_COLL_NAME}"`);
284
+
278
285
  if (!universalSocialSnap.empty) {
279
- logger.log('DEBUG', `[RootDataIndexer/${dateStr}] Found ${universalSocialSnap.docs.length} social posts in query`);
286
+ logger.log('INFO', `[RootDataIndexer/${dateStr}] Collection group query returned ${universalSocialSnap.docs.length} posts`);
287
+
288
+ // Track all paths found for debugging
289
+ const allPaths = [];
290
+ const piPaths = [];
291
+ const signedInPaths = [];
292
+ const otherPaths = [];
293
+
280
294
  universalSocialSnap.docs.forEach(doc => {
281
295
  const path = doc.ref.path;
282
296
  const data = doc.data();
283
297
  const fetchedAt = data.fetchedAt;
298
+ allPaths.push(path);
299
+
300
+ // Convert fetchedAt to string for logging
301
+ let fetchedAtStr = 'missing';
302
+ if (fetchedAt) {
303
+ if (fetchedAt.toDate) {
304
+ fetchedAtStr = fetchedAt.toDate().toISOString();
305
+ } else if (fetchedAt.toMillis) {
306
+ fetchedAtStr = new Date(fetchedAt.toMillis()).toISOString();
307
+ } else {
308
+ fetchedAtStr = String(fetchedAt);
309
+ }
310
+ }
284
311
 
285
- // Use includes() to match collection name anywhere in path (more robust)
312
+ // Use includes() to match collection name anywhere in path
286
313
  // Path format: {collectionName}/{userId}/posts/{postId}
287
- // Firestore paths don't have leading slash, so check both with and without
288
314
  const piMatchPattern = `${PI_SOCIAL_COLL_NAME}/`;
289
315
  const signedInMatchPattern = `${SIGNED_IN_SOCIAL_COLL_NAME}/`;
290
316
 
291
- if (path.includes(piMatchPattern) || path.startsWith(piMatchPattern)) {
317
+ if (path.includes(piMatchPattern)) {
292
318
  foundPISocial = true;
293
- logger.log('DEBUG', `[RootDataIndexer/${dateStr}] Found PI social: ${path}`);
294
- }
295
- if (path.includes(signedInMatchPattern) || path.startsWith(signedInMatchPattern)) {
319
+ piPaths.push({ path, fetchedAt: fetchedAtStr });
320
+ logger.log('INFO', `[RootDataIndexer/${dateStr}] ✓ PI social: ${path} (fetchedAt: ${fetchedAtStr})`);
321
+ } else if (path.includes(signedInMatchPattern)) {
296
322
  foundSignedInSocial = true;
297
- const fetchedAtStr = fetchedAt ? (fetchedAt.toDate ? fetchedAt.toDate().toISOString() : String(fetchedAt)) : 'missing';
298
- logger.log('DEBUG', `[RootDataIndexer/${dateStr}] ✓ Found signed-in social: ${path}, fetchedAt: ${fetchedAtStr}`);
299
- } else if (!path.includes(piMatchPattern)) {
300
- // Log paths that don't match either pattern to help debug
301
- logger.log('DEBUG', `[RootDataIndexer/${dateStr}] Path doesn't match: ${path} (looking for: "${signedInMatchPattern}" or "${piMatchPattern}")`);
323
+ signedInPaths.push({ path, fetchedAt: fetchedAtStr });
324
+ logger.log('INFO', `[RootDataIndexer/${dateStr}] ✓ Signed-in social: ${path} (fetchedAt: ${fetchedAtStr})`);
325
+ } else {
326
+ otherPaths.push({ path, fetchedAt: fetchedAtStr });
327
+ logger.log('INFO', `[RootDataIndexer/${dateStr}] ? Other social: ${path} (fetchedAt: ${fetchedAtStr})`);
302
328
  }
303
329
  });
330
+
331
+ logger.log('INFO', `[RootDataIndexer/${dateStr}] Summary - Total: ${allPaths.length}, PI: ${piPaths.length}, Signed-in: ${signedInPaths.length}, Other: ${otherPaths.length}`);
332
+
333
+ if (signedInPaths.length === 0 && !foundSignedInSocial) {
334
+ logger.log('WARN', `[RootDataIndexer/${dateStr}] ⚠️ No signed-in social posts found! Expected pattern: "${signedInMatchPattern}"`);
335
+ logger.log('WARN', `[RootDataIndexer/${dateStr}] All paths found: ${allPaths.slice(0, 10).join(', ')}${allPaths.length > 10 ? '...' : ''}`);
336
+ }
304
337
  } else {
305
- logger.log('DEBUG', `[RootDataIndexer/${dateStr}] No social posts found in query (dayStart: ${dayStart.toISOString()}, dayEnd: ${dayEnd.toISOString()})`);
338
+ logger.log('WARN', `[RootDataIndexer/${dateStr}] ⚠️ Collection group query returned NO posts! (dayStart: ${dayStart.toISOString()}, dayEnd: ${dayEnd.toISOString()})`);
339
+ logger.log('WARN', `[RootDataIndexer/${dateStr}] This might indicate: 1) No posts with fetchedAt in this range, 2) Missing Firestore index, or 3) Query error`);
306
340
  }
307
341
 
308
342
  // --- Assign to Availability ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.469",
3
+ "version": "1.0.470",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [