@xuda.io/ai_module 1.1.5031 → 1.1.5033
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 +13 -22
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1285,50 +1285,41 @@ 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
|
-
|
|
1289
|
-
// 1. Determine Sort Pattern and Key Prefix
|
|
1290
1288
|
const sortType = reference_id ? 'ref' : 'ts';
|
|
1289
|
+
const filter = filter_type || 'all'; // Ensure this matches a string in the Map 'types' array
|
|
1291
1290
|
|
|
1292
|
-
//
|
|
1293
|
-
//
|
|
1294
|
-
let startkey = [profileId,
|
|
1295
|
-
let endkey = [profileId,
|
|
1291
|
+
// Logic: [profileId, filter, conversation_type, sortType, ...]
|
|
1292
|
+
// We use null for start and {} for end to catch ALL conversation_types
|
|
1293
|
+
let startkey = [profileId, filter, conversation_type || null, sortType];
|
|
1294
|
+
let endkey = [profileId, filter, conversation_type || {}, sortType];
|
|
1296
1295
|
|
|
1297
1296
|
if (reference_id) {
|
|
1298
|
-
// Exact match for reference_id
|
|
1297
|
+
// Exact match for the reference_id section
|
|
1299
1298
|
startkey.push(reference_id);
|
|
1300
|
-
endkey.push(reference_id, {}); //
|
|
1299
|
+
endkey.push(reference_id, {}); // Includes all timestamps for this ref
|
|
1301
1300
|
} else {
|
|
1302
|
-
//
|
|
1301
|
+
// High-to-low range for descending timestamps
|
|
1303
1302
|
startkey.push({});
|
|
1304
1303
|
endkey.push(0);
|
|
1305
1304
|
}
|
|
1306
1305
|
|
|
1307
|
-
// 3. Construct Query Object
|
|
1308
1306
|
const query = {
|
|
1309
1307
|
include_docs: true,
|
|
1310
|
-
startkey: startkey,
|
|
1308
|
+
startkey: startkey,
|
|
1311
1309
|
endkey: endkey,
|
|
1312
|
-
// Cast to Number to prevent CouchDB "Invalid value" errors
|
|
1313
1310
|
limit: parseInt(limit) || 9999,
|
|
1314
1311
|
skip: parseInt(skip) || 0,
|
|
1315
|
-
descending: !reference_id,
|
|
1312
|
+
descending: !reference_id, // true for 'ts', false for 'ref'
|
|
1316
1313
|
};
|
|
1317
1314
|
|
|
1318
|
-
if (search)
|
|
1319
|
-
query.search = encodeURIComponent(search);
|
|
1320
|
-
}
|
|
1315
|
+
if (search) query.search = encodeURIComponent(search);
|
|
1321
1316
|
|
|
1322
|
-
|
|
1323
|
-
// Adjusted to match your signature without the redundant 'chats' arg
|
|
1324
|
-
const response = await db_module.call_app_list_function(
|
|
1317
|
+
return await db_module.call_app_list_function(
|
|
1325
1318
|
account_profile_info.app_id,
|
|
1326
|
-
'by_profile', // View Name
|
|
1319
|
+
'by_profile', // View Name
|
|
1327
1320
|
'filter_chats', // List Name
|
|
1328
1321
|
query,
|
|
1329
1322
|
);
|
|
1330
|
-
|
|
1331
|
-
return response;
|
|
1332
1323
|
};
|
|
1333
1324
|
|
|
1334
1325
|
////// FROM - IN
|