Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export usage csv i18n #3660

Merged
merged 2 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/web/i18n/en/account_usage.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"every_month": "Moon",
"export_confirm": "Export confirmation",
"export_confirm_tip": "There are currently {{total}} usage records in total. Are you sure to export?",
"export_title": "Time,Members,Type,Project name,AI points",
"feishu": "Feishu",
"generation_time": "Generation time",
"input_token_length": "input tokens",
Expand Down
1 change: 1 addition & 0 deletions packages/web/i18n/zh-CN/account_usage.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"export_confirm": "导出确认",
"export_confirm_tip": "当前共 {{total}} 条使用记录,确认导出?",
"export_success": "导出成功",
"export_title": "时间,成员,类型,项目名,AI 积分消耗",
"feishu": "飞书",
"generation_time": "生成时间",
"input_token_length": "输入 tokens",
Expand Down
1 change: 1 addition & 0 deletions packages/web/i18n/zh-Hant/account_usage.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"every_month": "月",
"export_confirm": "導出確認",
"export_confirm_tip": "當前共 {{total}} 筆使用記錄,確認導出?",
"export_title": "時間,成員,類型,項目名,AI 積分消耗",
"feishu": "飛書",
"generation_time": "生成時間",
"input_token_length": "輸入 tokens",
Expand Down
57 changes: 40 additions & 17 deletions projects/app/src/pageComponents/account/usage/UsageTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,47 @@ const UsageTableList = ({

const { dateRange, selectTmbIds, isSelectAllTmb, usageSources, isSelectAllSource, projectName } =
filterParams;
const requestParans = useMemo(
() => ({
const requestParams = useMemo(() => {
const appNameMap = {
['core.app.Question Guide']: t('common:core.app.Question Guide'),
['common:support.wallet.usage.Audio Speech']: t('common:support.wallet.usage.Audio Speech'),
['support.wallet.usage.Whisper']: t('common:support.wallet.usage.Whisper'),
['support.wallet.moduleName.index']: t('common:support.wallet.moduleName.index'),
['support.wallet.moduleName.qa']: t('common:support.wallet.moduleName.qa'),
['core.dataset.training.Auto mode']: t('common:core.dataset.training.Auto mode'),
['common:core.module.template.ai_chat']: t('common:core.module.template.ai_chat')
};

const sourcesMap = Object.fromEntries(
Object.entries(UsageSourceMap).map(([key, config]) => [
key,
{
label: t(config.label as any)
}
])
);
const title = t('account_usage:export_title');

return {
dateStart: dateRange.from || new Date(),
dateEnd: addDays(dateRange.to || new Date(), 1),
sources: isSelectAllSource ? undefined : usageSources,
sourcesMap,
appNameMap,
title,
teamMemberIds: isSelectAllTmb ? undefined : selectTmbIds,
projectName
}),
[
dateRange.from,
dateRange.to,
isSelectAllSource,
isSelectAllTmb,
projectName,
selectTmbIds,
usageSources
]
);
};
}, [
dateRange.from,
dateRange.to,
isSelectAllSource,
isSelectAllTmb,
projectName,
selectTmbIds,
usageSources,
t
]);

const {
data: usages,
Expand All @@ -69,8 +92,8 @@ const UsageTableList = ({
total
} = usePagination(getUserUsages, {
pageSize: 20,
params: requestParans,
refreshDeps: [requestParans]
params: requestParams,
refreshDeps: [requestParams]
});

const [usageDetail, setUsageDetail] = useState<UsageItemType>();
Expand All @@ -80,11 +103,11 @@ const UsageTableList = ({
await downloadFetch({
url: `/api/proApi/support/wallet/usage/exportUsage`,
filename: `usage.csv`,
body: requestParans
body: requestParams
});
},
{
refreshDeps: [requestParans]
refreshDeps: [requestParams]
}
);

Expand Down
Loading