@xuda.io/account_module 1.2.1251 → 1.2.1253

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 +2 -2
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2439,7 +2439,7 @@ export const onboarding_completed = async function (req, job_id, headers) {
2439
2439
 
2440
2440
  let _design = await db_module.get_app_couch_doc_native(account_doc.account_project_id, '_design/xuda');
2441
2441
  if (!_design.views.ai_chat_usage) {
2442
- _design.views[ai_chat_usage] = {
2442
+ _design.views['ai_chat_usage'] = {
2443
2443
  map: "function formatTimestampToDDMMYYYY(timestampMs) {\n const date = new Date(timestampMs); // directly use milliseconds\n\n const day = Number(String(date.getDate()).padStart(2, '0'));\n const month =Number( String(date.getMonth() + 1).padStart(2, '0')); // months are 0-based\n const year = date.getFullYear();\n\n // return `${day}/${month}/${year}`;\n return {day,month,year}\n}\n\nfunction (doc) {\n \n if(doc.docType===\"chat_usage\"){\n if(doc.cost && doc.account_profile_info){\n const cost_input=(doc.cost.input/1000000)*doc.input_tokens*100 ;\n const cost_output=(doc.cost.output/1000000)*doc.output_tokens*100 \n \n const d=formatTimestampToDDMMYYYY(doc.date_created_ts)\n emit([d.year,d.month,d.day,doc.account_profile_info.account_profile_id,doc.account_profile_info.account_profile_obj.uid,doc.model], [doc.input_tokens,doc.output_tokens ,cost_input,cost_output]);\n // emit([d.year,d.month,d.day,doc.model], [doc.input_tokens,doc.output_tokens]);\n}\n }\n }",
2444
2444
  reduce: '_sum',
2445
2445
  };
@@ -2749,7 +2749,7 @@ export const get_account_profile_info = async function (uid, contact_profile_doc
2749
2749
  const user_account_profiles = await get_user_account_profiles();
2750
2750
  debugger;
2751
2751
  const usage_ret = await get_account_ai_usage({ uid });
2752
- doc.max_credits = usage_ret.data.credits.total;
2752
+ doc.max_credits = usage_ret.data.credits.total / user_account_profiles.length;
2753
2753
  doc.used_credits = usage_ret.data.usage.total;
2754
2754
 
2755
2755
  return doc;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.1251",
3
+ "version": "1.2.1253",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {