@xuda.io/ai_module 1.1.5032 → 1.1.5034
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 +64 -38
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1284,52 +1284,78 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1284
1284
|
};
|
|
1285
1285
|
|
|
1286
1286
|
const get_data_view = async function () {
|
|
1287
|
-
const profileId = account_profile_info.is_main ? 'ADMIN_OR_ALL' : account_profile_info.account_profile_id;
|
|
1287
|
+
// const profileId = account_profile_info.is_main ? 'ADMIN_OR_ALL' : account_profile_info.account_profile_id;
|
|
1288
|
+
// debugger;
|
|
1289
|
+
// // 1. Determine Sort Pattern and Key Prefix
|
|
1290
|
+
// const sortType = reference_id ? 'ref' : 'ts';
|
|
1288
1291
|
|
|
1289
|
-
//
|
|
1290
|
-
|
|
1292
|
+
// // 2. Build Base Key
|
|
1293
|
+
// // Key Structure: [profileId, type, convType, sortType, sortVal1, sortVal2]
|
|
1294
|
+
// let startkey = [profileId, filter_type, conversation_type || null, sortType];
|
|
1295
|
+
// let endkey = [profileId, filter_type, conversation_type || null, sortType];
|
|
1291
1296
|
|
|
1292
|
-
//
|
|
1293
|
-
//
|
|
1294
|
-
//
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
+
// if (reference_id) {
|
|
1298
|
+
// startkey.push(reference_id);
|
|
1299
|
+
// endkey.push(reference_id, {}); // {} acts as a high-value sentinel
|
|
1300
|
+
// } else {
|
|
1301
|
+
// startkey.push({}); // For 'ts' descending, start at the "highest" possible value
|
|
1302
|
+
// endkey.push(0);
|
|
1303
|
+
// }
|
|
1297
1304
|
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
}
|
|
1305
|
+
// // 3. Construct Query
|
|
1306
|
+
// const query = {
|
|
1307
|
+
// include_docs: true, // Required for list function search and data retrieval
|
|
1308
|
+
// startkey: JSON.stringify(startkey),
|
|
1309
|
+
// endkey: JSON.stringify(endkey),
|
|
1310
|
+
// limit,
|
|
1311
|
+
// skip,
|
|
1312
|
+
// descending: !reference_id, // Descending for 'ts', Ascending for 'ref'
|
|
1313
|
+
// };
|
|
1308
1314
|
|
|
1309
|
-
//
|
|
1310
|
-
const query = {
|
|
1311
|
-
include_docs: true,
|
|
1312
|
-
startkey: startkey, // Pass as Array for Nano
|
|
1313
|
-
endkey: endkey,
|
|
1314
|
-
limit: parseInt(limit) || 9999,
|
|
1315
|
-
skip: parseInt(skip) || 0,
|
|
1316
|
-
descending: !reference_id,
|
|
1317
|
-
};
|
|
1315
|
+
// if (search) query.search = encodeURIComponent(search);
|
|
1318
1316
|
|
|
1319
|
-
|
|
1320
|
-
|
|
1317
|
+
// // 4. Call the List Function
|
|
1318
|
+
// // URL: /db/_design/chats/_list/filter_chats/by_profile
|
|
1319
|
+
// const response = await db_module.call_app_list_function(account_profile_info.app_id, 'by_profile', 'filter_chats', query);
|
|
1320
|
+
|
|
1321
|
+
// return response;
|
|
1322
|
+
|
|
1323
|
+
//====================
|
|
1324
|
+
|
|
1325
|
+
let stat = 3;
|
|
1326
|
+
|
|
1327
|
+
switch (filter_type) {
|
|
1328
|
+
case 'archived': {
|
|
1329
|
+
stat = 5;
|
|
1330
|
+
break;
|
|
1331
|
+
}
|
|
1332
|
+
case 'shared': {
|
|
1333
|
+
opt.selector.shared_from_uid = { $gt: null };
|
|
1334
|
+
// opt.selector.team_req_stat = { $eq: 3 };
|
|
1335
|
+
break;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
case 'mine': {
|
|
1339
|
+
opt.selector.uid = uid;
|
|
1340
|
+
|
|
1341
|
+
break;
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
default:
|
|
1345
|
+
// opt.selector.team_req_stat = { $eq: 3 };
|
|
1346
|
+
break;
|
|
1321
1347
|
}
|
|
1322
1348
|
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
);
|
|
1349
|
+
const ret = await db_module.get_app_couch_view(account_profile_info.app_id, 'ai_chat_list', {
|
|
1350
|
+
startkey: [stat, reference_id, 0],
|
|
1351
|
+
endkey: [stat, reference_id, 9999999999999],
|
|
1352
|
+
limit: limit || 9999,
|
|
1353
|
+
skip: skip || 0,
|
|
1354
|
+
include_docs: true,
|
|
1355
|
+
descending: reference_id ? false : true,
|
|
1356
|
+
});
|
|
1331
1357
|
|
|
1332
|
-
|
|
1358
|
+
debugger;
|
|
1333
1359
|
};
|
|
1334
1360
|
|
|
1335
1361
|
////// FROM - IN
|