@xuda.io/ai_module 1.1.5032 → 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 +14 -24
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1285,51 +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
|
-
|
|
1295
|
-
let
|
|
1296
|
-
let endkey = [profileId, filter_type || 'all', conversation_type || {}, sortType];
|
|
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];
|
|
1297
1295
|
|
|
1298
1296
|
if (reference_id) {
|
|
1299
|
-
// Exact match for reference_id
|
|
1297
|
+
// Exact match for the reference_id section
|
|
1300
1298
|
startkey.push(reference_id);
|
|
1301
|
-
|
|
1302
|
-
endkey.push(reference_id, {});
|
|
1299
|
+
endkey.push(reference_id, {}); // Includes all timestamps for this ref
|
|
1303
1300
|
} else {
|
|
1304
|
-
//
|
|
1301
|
+
// High-to-low range for descending timestamps
|
|
1305
1302
|
startkey.push({});
|
|
1306
1303
|
endkey.push(0);
|
|
1307
1304
|
}
|
|
1308
1305
|
|
|
1309
|
-
// 3. Construct Query Object
|
|
1310
1306
|
const query = {
|
|
1311
1307
|
include_docs: true,
|
|
1312
|
-
startkey: startkey,
|
|
1308
|
+
startkey: startkey,
|
|
1313
1309
|
endkey: endkey,
|
|
1314
1310
|
limit: parseInt(limit) || 9999,
|
|
1315
1311
|
skip: parseInt(skip) || 0,
|
|
1316
|
-
descending: !reference_id,
|
|
1312
|
+
descending: !reference_id, // true for 'ts', false for 'ref'
|
|
1317
1313
|
};
|
|
1318
1314
|
|
|
1319
|
-
if (search)
|
|
1320
|
-
query.search = encodeURIComponent(search);
|
|
1321
|
-
}
|
|
1315
|
+
if (search) query.search = encodeURIComponent(search);
|
|
1322
1316
|
|
|
1323
|
-
|
|
1324
|
-
// Ensure the order matches your Nano documentation: (ddoc, view, list, query)
|
|
1325
|
-
const response = await db_module.call_app_list_function(
|
|
1317
|
+
return await db_module.call_app_list_function(
|
|
1326
1318
|
account_profile_info.app_id,
|
|
1327
|
-
'by_profile', //
|
|
1328
|
-
'filter_chats', //
|
|
1319
|
+
'by_profile', // View Name
|
|
1320
|
+
'filter_chats', // List Name
|
|
1329
1321
|
query,
|
|
1330
1322
|
);
|
|
1331
|
-
|
|
1332
|
-
return response;
|
|
1333
1323
|
};
|
|
1334
1324
|
|
|
1335
1325
|
////// FROM - IN
|