@xuda.io/ai_module 1.1.5033 → 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.
Files changed (2) hide show
  1. package/index.mjs +66 -30
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1284,42 +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;
1288
- const sortType = reference_id ? 'ref' : 'ts';
1289
- const filter = filter_type || 'all'; // Ensure this matches a string in the Map 'types' array
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';
1290
1291
 
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];
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];
1295
1296
 
1296
- if (reference_id) {
1297
- // Exact match for the reference_id section
1298
- startkey.push(reference_id);
1299
- endkey.push(reference_id, {}); // Includes all timestamps for this ref
1300
- } else {
1301
- // High-to-low range for descending timestamps
1302
- startkey.push({});
1303
- endkey.push(0);
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
+ // }
1304
+
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
+ // };
1314
+
1315
+ // if (search) query.search = encodeURIComponent(search);
1316
+
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;
1304
1347
  }
1305
1348
 
1306
- const query = {
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,
1307
1354
  include_docs: true,
1308
- startkey: startkey,
1309
- endkey: endkey,
1310
- limit: parseInt(limit) || 9999,
1311
- skip: parseInt(skip) || 0,
1312
- descending: !reference_id, // true for 'ts', false for 'ref'
1313
- };
1314
-
1315
- if (search) query.search = encodeURIComponent(search);
1355
+ descending: reference_id ? false : true,
1356
+ });
1316
1357
 
1317
- return await db_module.call_app_list_function(
1318
- account_profile_info.app_id,
1319
- 'by_profile', // View Name
1320
- 'filter_chats', // List Name
1321
- query,
1322
- );
1358
+ debugger;
1323
1359
  };
1324
1360
 
1325
1361
  ////// FROM - IN
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.5033",
3
+ "version": "1.1.5034",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",