fix: add backend field in evaluation payload

This commit is contained in:
jialin
2025-04-08 14:37:31 +08:00
parent f6bc183972
commit c09503aad8
5 changed files with 41 additions and 38 deletions
+16 -17
View File
@@ -1,3 +1,5 @@
import _ from 'lodash';
export const isNotEmptyValue = (value: any) => {
if (Array.isArray(value)) {
return value.length > 0;
@@ -20,25 +22,22 @@ export const handleBatchRequest = async (
};
export const convertFileSize = (
sizeInBytes: number | undefined,
prec?: number,
sizeInBytes?: number,
prec = 1,
allowEmpty = false
) => {
const precision = prec ?? 1;
if (!sizeInBytes) {
return allowEmpty ? '' : '0';
}
if (sizeInBytes < 1024) {
return `${sizeInBytes.toFixed(precision)} B`;
} else if (sizeInBytes < 1024 * 1024) {
return `${(sizeInBytes / 1024).toFixed(precision)} KiB`;
} else if (sizeInBytes < 1024 * 1024 * 1024) {
return `${(sizeInBytes / (1024 * 1024)).toFixed(precision)} MiB`;
} else if (sizeInBytes < 1024 * 1024 * 1024 * 1024) {
return `${(sizeInBytes / (1024 * 1024 * 1024)).toFixed(precision)} GiB`;
} else {
return `${(sizeInBytes / (1024 * 1024 * 1024 * 1024)).toFixed(precision)} TiB`;
): string => {
if (!sizeInBytes) return allowEmpty ? '' : '0';
const units = ['B', 'KiB', 'MiB', 'GiB', 'TiB'];
let size = sizeInBytes;
let unitIndex = 0;
while (size >= 1024 && unitIndex < units.length - 1) {
size /= 1024;
unitIndex++;
}
return `${_.round(size, prec)} ${units[unitIndex]}`;
};
export const platformCall = () => {