@xuda.io/account_module 1.2.984 → 1.2.986
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 +26 -23
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -482,27 +482,6 @@ export const get_account_data = async function (req) {
|
|
|
482
482
|
try {
|
|
483
483
|
const { data: acc_obj } = await db_module.get_couch_doc('xuda_accounts', uid);
|
|
484
484
|
|
|
485
|
-
const app_id = await get_account_default_project_id(uid);
|
|
486
|
-
|
|
487
|
-
const d = new Date(); // directly use milliseconds
|
|
488
|
-
|
|
489
|
-
const month = Number(String(d.getMonth() + 1).padStart(2, '0')); // months are 0-based
|
|
490
|
-
const year = d.getFullYear();
|
|
491
|
-
|
|
492
|
-
const ai_usage = await db_module.get_app_couch_view(app_id, 'ai_chat_usage', {
|
|
493
|
-
startkey: [year, month, 0],
|
|
494
|
-
endkey: [year, month, 99],
|
|
495
|
-
reduce: true,
|
|
496
|
-
group_level: 999,
|
|
497
|
-
});
|
|
498
|
-
console.log('ai_usage', ai_usage.rows);
|
|
499
|
-
for (const row of ai_usage.rows) {
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
let membership_plan = 0;
|
|
503
|
-
let ai_workspace_plan = 0;
|
|
504
|
-
let contact_connection = 0;
|
|
505
|
-
|
|
506
485
|
var ret = { code: 1 };
|
|
507
486
|
ret.data = {
|
|
508
487
|
_id: acc_obj._id,
|
|
@@ -540,7 +519,7 @@ export const get_account_data = async function (req) {
|
|
|
540
519
|
project_data_size: acc_obj.project_data_size || 0,
|
|
541
520
|
total_drive_size: acc_obj.total_drive_size || 0,
|
|
542
521
|
},
|
|
543
|
-
|
|
522
|
+
|
|
544
523
|
stripe_connect_account_id: acc_obj?.stripe_connect_account_obj?.id,
|
|
545
524
|
stripe_connect_account_status: acc_obj?.stripe_connect_account_status,
|
|
546
525
|
};
|
|
@@ -2420,4 +2399,28 @@ export const ts_contact = async function (contact_id) {
|
|
|
2420
2399
|
}
|
|
2421
2400
|
};
|
|
2422
2401
|
|
|
2423
|
-
export const get_ai_usage = async function (
|
|
2402
|
+
export const get_ai_usage = async function (req, job_id, headers) {
|
|
2403
|
+
const { uid } = req;
|
|
2404
|
+
const app_id = await get_account_default_project_id(uid);
|
|
2405
|
+
|
|
2406
|
+
const d = new Date(); // directly use milliseconds
|
|
2407
|
+
|
|
2408
|
+
const month = Number(String(d.getMonth() + 1).padStart(2, '0')); // months are 0-based
|
|
2409
|
+
const year = d.getFullYear();
|
|
2410
|
+
|
|
2411
|
+
const ai_usage = await db_module.get_app_couch_view(app_id, 'ai_chat_usage', {
|
|
2412
|
+
startkey: [year, month, 0],
|
|
2413
|
+
endkey: [year, month, 99],
|
|
2414
|
+
reduce: true,
|
|
2415
|
+
group_level: 999,
|
|
2416
|
+
});
|
|
2417
|
+
console.log('ai_usage', ai_usage.rows);
|
|
2418
|
+
for (const row of ai_usage.rows) {
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2421
|
+
let membership_plan = 0;
|
|
2422
|
+
let ai_workspace_plan = 0;
|
|
2423
|
+
let contact_connection = 0;
|
|
2424
|
+
|
|
2425
|
+
let ai_credits = { credits: [{ membership_plan }, { ai_workspace_plan }, { contact_connection }], usage: { profile: [], projects: [] } };
|
|
2426
|
+
};
|