@xuda.io/account_module 1.2.2169 → 1.2.2170
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 +3 -26
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -3393,7 +3393,7 @@ export const get_account_ai_usage = async function (req, job_id, headers) {
|
|
|
3393
3393
|
const timestamp_to = new Date(Number(year_to) || year, (Number(month_to) || month) - 1, Number(day_to) || day).getTime();
|
|
3394
3394
|
|
|
3395
3395
|
const query = {
|
|
3396
|
-
|
|
3396
|
+
include_docs: true,
|
|
3397
3397
|
startkey: [uid, timestamp_from],
|
|
3398
3398
|
endkey: [uid, timestamp_to],
|
|
3399
3399
|
// reduce: true,
|
|
@@ -3403,31 +3403,8 @@ export const get_account_ai_usage = async function (req, job_id, headers) {
|
|
|
3403
3403
|
|
|
3404
3404
|
// console.log('ai_usage', ai_usage.rows);
|
|
3405
3405
|
debugger;
|
|
3406
|
-
let total_usage =
|
|
3407
|
-
let profile =
|
|
3408
|
-
|
|
3409
|
-
for (const row of ai_usage.data.rows) {
|
|
3410
|
-
const user = row.key[0];
|
|
3411
|
-
const year = row.key[1];
|
|
3412
|
-
const month = row.key[2];
|
|
3413
|
-
const day = row.key[3];
|
|
3414
|
-
const account_profile_id = row.key[4];
|
|
3415
|
-
const uid = row.key[5];
|
|
3416
|
-
const model = row.key[6];
|
|
3417
|
-
const input_tokens = row.value[0];
|
|
3418
|
-
const output_tokens = row.value[1];
|
|
3419
|
-
const input_credits = row.value[2];
|
|
3420
|
-
const output_credits = row.value[3];
|
|
3421
|
-
if (!profile[account_profile_id]) {
|
|
3422
|
-
profile[account_profile_id] = {};
|
|
3423
|
-
}
|
|
3424
|
-
if (!profile[account_profile_id][uid]) {
|
|
3425
|
-
profile[account_profile_id][uid] = 0;
|
|
3426
|
-
}
|
|
3427
|
-
|
|
3428
|
-
profile[account_profile_id][uid] += input_credits + output_credits;
|
|
3429
|
-
total_usage += input_credits + output_credits;
|
|
3430
|
-
}
|
|
3406
|
+
let total_usage = response.total_usage;
|
|
3407
|
+
let profile = response.profiles;
|
|
3431
3408
|
|
|
3432
3409
|
const ai_credits = await db_module.get_couch_view('xuda_billing', 'ai_credits', {
|
|
3433
3410
|
startkey: [uid, ''],
|