@xuda.io/account_module 1.2.1026 → 1.2.1027
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 +5 -5
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2406,18 +2406,18 @@ export const ts_contact = async function (contact_id) {
|
|
|
2406
2406
|
};
|
|
2407
2407
|
|
|
2408
2408
|
export const get_account_ai_usage = async function (req, job_id, headers) {
|
|
2409
|
-
const { uid } = req;
|
|
2409
|
+
const { uid, year, month, day } = req;
|
|
2410
2410
|
try {
|
|
2411
2411
|
const app_id = await get_account_default_project_id(uid);
|
|
2412
2412
|
const { data: acc_obj } = await db_module.get_couch_doc('xuda_accounts', uid);
|
|
2413
2413
|
|
|
2414
2414
|
const d = new Date();
|
|
2415
|
-
const
|
|
2416
|
-
const
|
|
2415
|
+
const curr_month = Number(String(d.getMonth() + 1).padStart(2, '0')); // months are 0-based
|
|
2416
|
+
const curr_year = d.getFullYear();
|
|
2417
2417
|
|
|
2418
2418
|
const ai_usage = await db_module.get_app_couch_view(app_id, 'ai_chat_usage', {
|
|
2419
|
-
startkey: [year, month, 0],
|
|
2420
|
-
endkey: [year, month, 99],
|
|
2419
|
+
startkey: [year || curr_year, month || curr_month, day || 0],
|
|
2420
|
+
endkey: [year || curr_year, month || curr_month, day || 99],
|
|
2421
2421
|
reduce: true,
|
|
2422
2422
|
group_level: 999,
|
|
2423
2423
|
});
|