@xuda.io/account_module 1.2.1554 → 1.2.1555

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 +20 -2
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1842,7 +1842,7 @@ export const get_account_ai_usage = async function (req, job_id, headers) {
1842
1842
 
1843
1843
  let total_usage = 0;
1844
1844
  let profile = {};
1845
- debugger;
1845
+
1846
1846
  for (const row of ai_usage.data.rows) {
1847
1847
  const user = row.key[0];
1848
1848
  const year = row.key[1];
@@ -1877,7 +1877,25 @@ export const get_account_ai_usage = async function (req, job_id, headers) {
1877
1877
  reduce: true,
1878
1878
  group_level: 999,
1879
1879
  });
1880
- console.log('ai_credits', ai_credits);
1880
+
1881
+ let credits_obj, total_credits;
1882
+ for (const row of ai_credits.data.rows) {
1883
+ const user = row.key[0];
1884
+ const source = row.key[1];
1885
+
1886
+ const credits = row.value;
1887
+
1888
+ total_credits += credits;
1889
+
1890
+ if (!credits_obj[source]) {
1891
+ credits_obj[source] = 0;
1892
+ }
1893
+ credits_obj[source] += credits;
1894
+
1895
+ profile[account_profile_id][uid] += input_credits + output_credits;
1896
+ total_usage += input_credits + output_credits;
1897
+ }
1898
+
1881
1899
  let data = { credits: {}, usage: { profile, projects: [], total: total_usage } };
1882
1900
 
1883
1901
  return { code: 55, data };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.1554",
3
+ "version": "1.2.1555",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {