@peopl-health/nexus 3.9.8 → 3.9.9

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.
@@ -232,7 +232,7 @@ const searchConversationsController = async (req, res) => {
232
232
  { $group: { _id: '$_id', doc: { $first: '$$ROOT' } } },
233
233
  { $replaceRoot: { newRoot: '$doc' } },
234
234
  { $limit: parsedLimit }
235
- ]);
235
+ ], { allowDiskUse: true });
236
236
 
237
237
  const searchTime = Date.now() - searchStartTime;
238
238
  logger.info(`Search completed in ${searchTime}ms, found ${conversations.length} conversations`);
@@ -289,7 +289,7 @@ const searchConversationsController = async (req, res) => {
289
289
  { $match: { numero: { $in: phoneNumbers }, from_me: false, nombre_whatsapp: { $exists: true, $nin: [null, ''] } } },
290
290
  { $sort: { createdAt: -1 } },
291
291
  { $group: { _id: '$numero', nombre_whatsapp: { $first: '$nombre_whatsapp' } } }
292
- ]);
292
+ ], { allowDiskUse: true });
293
293
  lastPatientMessages.forEach(m => { messageNameMap[m._id] = m.nombre_whatsapp; });
294
294
  }
295
295
 
@@ -409,7 +409,7 @@ const getConversationsByNameController = async (req, res) => {
409
409
  }
410
410
  ];
411
411
 
412
- const [facetResult] = await Message.aggregate(pipeline);
412
+ const [facetResult] = await Message.aggregate(pipeline, { allowDiskUse: true });
413
413
 
414
414
  const conversations = facetResult?.data ?? [];
415
415
  const total = facetResult?.totalCount[0]?.total ?? 0;
@@ -53,7 +53,7 @@ const getConversationTokenUsage = async (numero, since = null) => {
53
53
  total_tokens: { $sum: '$token_usage.total_tokens' },
54
54
  request_count: { $sum: 1 },
55
55
  }}
56
- ]);
56
+ ], { allowDiskUse: true });
57
57
  return result || { _id: numero, total_input_tokens: 0, total_output_tokens: 0, total_tokens: 0, request_count: 0 };
58
58
  };
59
59
 
@@ -72,10 +72,10 @@ async function getDailyTrend(days) {
72
72
  const { startDate, today } = getMexicoDateRange(days);
73
73
 
74
74
  const patientPipeline = buildPatientMessagesPipeline(startDate);
75
- const patientData = await Message.aggregate(patientPipeline);
75
+ const patientData = await Message.aggregate(patientPipeline, { allowDiskUse: true });
76
76
 
77
77
  const toolPipeline = buildToolDistributionPipeline(startDate);
78
- const toolData = await Message.aggregate(toolPipeline);
78
+ const toolData = await Message.aggregate(toolPipeline, { allowDiskUse: true });
79
79
 
80
80
  const dailyData = mergeTrendData(patientData, toolData, today, days);
81
81
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "3.9.8",
3
+ "version": "3.9.9",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",