@xuda.io/ai_module 1.1.5093 → 1.1.5095
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.
- package/index.mjs +32 -6
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1290,7 +1290,7 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1290
1290
|
return ai_chats;
|
|
1291
1291
|
};
|
|
1292
1292
|
|
|
1293
|
-
const
|
|
1293
|
+
const get_data_view_conversation = async function () {
|
|
1294
1294
|
// const profileId = account_profile_info.is_main ? 'ADMIN_OR_ALL' : account_profile_info.account_profile_id;
|
|
1295
1295
|
// debugger;
|
|
1296
1296
|
// // 1. Determine Sort Pattern and Key Prefix
|
|
@@ -1331,9 +1331,6 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1331
1331
|
|
|
1332
1332
|
let stat_type = filter_type === 'archived' ? 'archived' : 'all';
|
|
1333
1333
|
|
|
1334
|
-
// const profile_id = account_profile_info.is_main ? 'all' : account_profile_info.account_profile_id;
|
|
1335
|
-
// const conv_type = conversation_type ? conversation_type : 'all';
|
|
1336
|
-
|
|
1337
1334
|
const ret = await db_module.get_app_couch_view(account_profile_info.app_id, 'chat_conversation_list', {
|
|
1338
1335
|
startkey: [stat_type, reference_id, 0],
|
|
1339
1336
|
endkey: [stat_type, reference_id, 9999999999999],
|
|
@@ -1361,6 +1358,36 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1361
1358
|
return { docs };
|
|
1362
1359
|
};
|
|
1363
1360
|
|
|
1361
|
+
const get_data_view_conversation_items = async function () {
|
|
1362
|
+
let stat_type = filter_type === 'archived' ? 'archived' : 'all';
|
|
1363
|
+
|
|
1364
|
+
const ret = await db_module.get_app_couch_view(account_profile_info.app_id, 'chat_conversation_list_items', {
|
|
1365
|
+
startkey: [stat_type, reference_id, 0],
|
|
1366
|
+
endkey: [stat_type, reference_id, 9999999999999],
|
|
1367
|
+
limit: parseInt(limit) || 9999,
|
|
1368
|
+
skip: parseInt(skip) || 0,
|
|
1369
|
+
include_docs: true,
|
|
1370
|
+
descending: false,
|
|
1371
|
+
});
|
|
1372
|
+
|
|
1373
|
+
let conversations = {};
|
|
1374
|
+
let docs = [];
|
|
1375
|
+
for (let val of ret.rows || []) {
|
|
1376
|
+
if (!conversations[val.value.conversation_id]) {
|
|
1377
|
+
conversations[val.value.conversation_id] = {};
|
|
1378
|
+
}
|
|
1379
|
+
conversations[val.value.conversation_id][val.value.type] = val.doc;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
for (let val of ret.rows || []) {
|
|
1383
|
+
if (val.value.type === 'conversation_item') {
|
|
1384
|
+
docs.push(conversations[val.value.conversation_item_id]);
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
return { docs };
|
|
1389
|
+
};
|
|
1390
|
+
|
|
1364
1391
|
////// FROM - IN
|
|
1365
1392
|
let requests_from = { docs: [], total_docs: 0 };
|
|
1366
1393
|
|
|
@@ -1391,9 +1418,8 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1391
1418
|
let ai_chats = { docs: [], total_docs: 0 };
|
|
1392
1419
|
|
|
1393
1420
|
if (filter_type !== 'pending') {
|
|
1394
|
-
ai_chats = await get_data_view();
|
|
1395
1421
|
if (reference_id && reference_type === 'contacts') {
|
|
1396
|
-
ai_chats = await
|
|
1422
|
+
ai_chats = await get_data_view_conversation_items();
|
|
1397
1423
|
} else {
|
|
1398
1424
|
ai_chats = await get_data_find();
|
|
1399
1425
|
}
|