@xuda.io/ai_module 1.1.5582 → 1.1.5584

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.
Files changed (2) hide show
  1. package/index.mjs +17 -37
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2283,49 +2283,29 @@ export const unarchive_ai_agent = async function (req) {
2283
2283
  };
2284
2284
 
2285
2285
  const update_agent_conversation_items_stat = async function (app_id, agent_id, stat, conversation_id) {
2286
- const conversation_ids = [];
2287
-
2288
- if (conversation_id) {
2289
- conversation_ids.push(conversation_id);
2290
- } else {
2291
- const conversations_ret = await db_module.find_app_couch_query(app_id, {
2292
- selector: {
2293
- docType: 'chat_conversation',
2294
- reference_id: agent_id,
2295
- },
2296
- fields: ['_id'],
2297
- limit: 9999,
2298
- });
2299
-
2300
- conversation_ids.push(...(conversations_ret.docs || []).map((doc) => doc._id).filter(Boolean));
2301
- }
2302
-
2303
- let updated = 0;
2286
+ const target_conversation_id = conversation_id || agent_id;
2304
2287
  const ts = Date.now();
2305
2288
 
2306
- for (const conversation_id of conversation_ids) {
2307
- const items_ret = await db_module.find_app_couch_query(app_id, {
2308
- selector: {
2309
- docType: 'chat_conversation_item',
2310
- conversation_id,
2311
- stat: { $lt: 4 },
2312
- },
2313
- limit: 9999,
2314
- });
2289
+ const items_ret = await db_module.find_app_couch_query(app_id, {
2290
+ selector: {
2291
+ docType: 'chat_conversation_item',
2292
+ conversation_id: target_conversation_id,
2293
+ stat: { $lt: 4 },
2294
+ },
2295
+ limit: 9999,
2296
+ });
2315
2297
 
2316
- const docs = (items_ret.docs || []).map((doc) => ({
2317
- ...doc,
2318
- stat,
2319
- ts,
2320
- }));
2298
+ const docs = (items_ret.docs || []).map((doc) => ({
2299
+ ...doc,
2300
+ stat,
2301
+ ts,
2302
+ }));
2321
2303
 
2322
- if (docs.length) {
2323
- await db_module.sava_app_couch_bulk_docs(app_id, docs);
2324
- updated += docs.length;
2325
- }
2304
+ if (docs.length) {
2305
+ await db_module.sava_app_couch_bulk_docs(app_id, docs);
2326
2306
  }
2327
2307
 
2328
- return updated;
2308
+ return docs.length;
2329
2309
  };
2330
2310
 
2331
2311
  export const archive_ai_agent = async function (req) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.5582",
3
+ "version": "1.1.5584",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",