@xuda.io/ai_module 1.1.5028 → 1.1.5030
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 +27 -49
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1285,73 +1285,51 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1285
1285
|
|
|
1286
1286
|
const get_data_view = async function () {
|
|
1287
1287
|
const profileId = account_profile_info.is_main ? 'ADMIN_OR_ALL' : account_profile_info.account_profile_id;
|
|
1288
|
-
|
|
1288
|
+
|
|
1289
1289
|
// 1. Determine Sort Pattern and Key Prefix
|
|
1290
1290
|
const sortType = reference_id ? 'ref' : 'ts';
|
|
1291
1291
|
|
|
1292
|
-
// 2. Build Base Key
|
|
1292
|
+
// 2. Build Base Key Arrays as raw objects
|
|
1293
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];
|
|
1294
|
+
let startkey = [profileId, filter_type || 'all', conversation_type || null, sortType];
|
|
1295
|
+
let endkey = [profileId, filter_type || 'all', conversation_type || null, sortType];
|
|
1296
1296
|
|
|
1297
1297
|
if (reference_id) {
|
|
1298
|
+
// Exact match for reference_id, sorted by date_created_ts ASC
|
|
1298
1299
|
startkey.push(reference_id);
|
|
1299
|
-
endkey.push(reference_id, {}); // {}
|
|
1300
|
+
endkey.push(reference_id, {}); // {} is the high-value sentinel
|
|
1300
1301
|
} else {
|
|
1301
|
-
|
|
1302
|
+
// For 'ts' descending, startkey must be the "highest" value
|
|
1303
|
+
startkey.push({});
|
|
1302
1304
|
endkey.push(0);
|
|
1303
1305
|
}
|
|
1304
1306
|
|
|
1305
|
-
// 3. Construct Query
|
|
1307
|
+
// 3. Construct Query Object
|
|
1306
1308
|
const query = {
|
|
1307
|
-
include_docs: true,
|
|
1308
|
-
startkey:
|
|
1309
|
-
endkey:
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1309
|
+
include_docs: true,
|
|
1310
|
+
startkey: startkey, // Pass as Array; Nano handles the stringification
|
|
1311
|
+
endkey: endkey,
|
|
1312
|
+
// Cast to Number to prevent CouchDB "Invalid value" errors
|
|
1313
|
+
limit: parseInt(limit) || 9999,
|
|
1314
|
+
skip: parseInt(skip) || 0,
|
|
1315
|
+
descending: !reference_id,
|
|
1313
1316
|
};
|
|
1314
1317
|
|
|
1315
|
-
if (search)
|
|
1318
|
+
if (search) {
|
|
1319
|
+
query.search = encodeURIComponent(search);
|
|
1320
|
+
}
|
|
1316
1321
|
|
|
1317
1322
|
// 4. Call the List Function
|
|
1318
|
-
//
|
|
1319
|
-
const response = await db_module.call_app_list_function(
|
|
1320
|
-
|
|
1321
|
-
return response;
|
|
1322
|
-
|
|
1323
|
-
// let stat = 3;
|
|
1323
|
+
// Adjusted to match your signature without the redundant 'chats' arg
|
|
1324
|
+
const response = await db_module.call_app_list_function(
|
|
1325
|
+
account_profile_info.app_id,
|
|
1324
1326
|
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
// }
|
|
1330
|
-
// case 'shared': {
|
|
1331
|
-
// opt.selector.shared_from_uid = { $gt: null };
|
|
1332
|
-
// // opt.selector.team_req_stat = { $eq: 3 };
|
|
1333
|
-
// break;
|
|
1334
|
-
// }
|
|
1335
|
-
|
|
1336
|
-
// case 'mine': {
|
|
1337
|
-
// opt.selector.uid = uid;
|
|
1338
|
-
|
|
1339
|
-
// break;
|
|
1340
|
-
// }
|
|
1341
|
-
|
|
1342
|
-
// default:
|
|
1343
|
-
// // opt.selector.team_req_stat = { $eq: 3 };
|
|
1344
|
-
// break;
|
|
1345
|
-
// }
|
|
1327
|
+
'by_profile', // View Name ,
|
|
1328
|
+
'filter_chats', // List Name
|
|
1329
|
+
query,
|
|
1330
|
+
);
|
|
1346
1331
|
|
|
1347
|
-
|
|
1348
|
-
// startkey: [stat, reference_id, 0],
|
|
1349
|
-
// endkey: [stat, reference_id, 9999999999999],
|
|
1350
|
-
// limit: limit || 9999,
|
|
1351
|
-
// skip: skip || 0,
|
|
1352
|
-
// include_docs: true,
|
|
1353
|
-
// descending: reference_id ? false : true,
|
|
1354
|
-
// });
|
|
1332
|
+
return response;
|
|
1355
1333
|
};
|
|
1356
1334
|
|
|
1357
1335
|
////// FROM - IN
|