Skip to content

Commit

Permalink
chore: merge 431
Browse files Browse the repository at this point in the history
  • Loading branch information
HSunboy committed Aug 20, 2024
2 parents 11dd34a + 01d2626 commit f8090a2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/component/Task/AlterDdlTask/CreateModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import type { ModalStore } from '@/store/modal';
import { useDBSession } from '@/store/sessionManager/hooks';
import { SettingStore } from '@/store/setting';
import { formatMessage } from '@/util/intl';
import { mbToKb } from '@/util/utils';
import { mbToB } from '@/util/utils';
import {
Alert,
Button,
Expand Down Expand Up @@ -147,7 +147,7 @@ const CreateDDLTaskModal: React.FC<IProps> = (props) => {
rowLimit || dataSizeLimit
? {
rowLimit,
dataSizeLimit: mbToKb(dataSizeLimit),
dataSizeLimit: mbToB(dataSizeLimit),
}
: null,
};
Expand Down
6 changes: 3 additions & 3 deletions src/component/Task/AlterDdlTask/DetailContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type { ITaskResult, TaskDetail } from '@/d.ts';
import { TaskExecStrategy, TaskStatus } from '@/d.ts';
import setting from '@/store/setting';
import { formatMessage } from '@/util/intl';
import { getFormatDateTime, kbToMb, mbToKb } from '@/util/utils';
import { bToMb, getFormatDateTime, kbToMb, mbToB, mbToKb } from '@/util/utils';
import { message, Typography } from 'antd';
import React from 'react';
import { SimpleTextItem } from '../../component/SimpleTextItem';
Expand Down Expand Up @@ -163,7 +163,7 @@ export function getItems(

const handleDataSizeLimit = async (dataSizeLimit, handleClose) => {
const res = await updateThrottleConfig(id, {
dataSizeLimit: mbToKb(dataSizeLimit),
dataSizeLimit: mbToB(dataSizeLimit),
rowLimit: parameters?.rateLimitConfig?.rowLimit,
});
if (res) {
Expand Down Expand Up @@ -348,7 +348,7 @@ export function getItems(
suffix="MB/s"
min={0}
max={OscMaxDataSizeLimit}
defaultValue={kbToMb(parameters?.rateLimitConfig?.dataSizeLimit)}
defaultValue={bToMb(parameters?.rateLimitConfig?.dataSizeLimit)}
onOk={handleDataSizeLimit}
readlOnly={cantBeModified}
/>,
Expand Down
10 changes: 10 additions & 0 deletions src/util/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,16 @@ export const kbToMb = (value: number) => {
return value / 1024;
};

// MB -> B
export const mbToB = (value: number) => {
return value * 1024 * 1024;
};

// B -> MB
export const bToMb = (value: number) => {
return value / 1024 / 1024;
};

/**
* https://tc39.es/proposal-array-grouping/#sec-object.groupby
* @param array object array => [{ level: 1, name: 'test1'}, { level: 1, name: 'test2'}, { level: 3, name: 'test3'}]
Expand Down

0 comments on commit f8090a2

Please sign in to comment.