Skip to content

Commit

Permalink
fix: 新建模型,存在多个度量的情况下,度量的扩展配置均会显示成第1个度量中的值; (tencentmusic#1909)
Browse files Browse the repository at this point in the history
* fix(semantic-model): 新建模型,存在多个度量的情况下,度量的扩展配置均会显示成第1个度量中的值

* refactor(semantic-model): 新建模型,扩展配置的取值方式,find重构成解构

---------

Co-authored-by: tristanliu <[email protected]>
  • Loading branch information
p1scess and sevenliu1896 authored Nov 20, 2024
1 parent 534da49 commit e990b37
Showing 1 changed file with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React, { useState } from 'react';
import { Table, Select, Checkbox, Input, Space, Tooltip, Form, Switch, Row, Col } from 'antd';
import { Checkbox, Form, Input, Select, Space, Switch, Table, Tooltip } from 'antd';
import TableTitleTooltips from '../../components/TableTitleTooltips';
import { isUndefined } from 'lodash';
import { ExclamationCircleOutlined } from '@ant-design/icons';
import SqlEditor from '@/components/SqlEditor';
import { ISemantic } from '../../data';
import {
TYPE_OPTIONS,
DATE_FORMATTER,
AGG_OPTIONS,
EnumDataSourceType,
DATE_FORMATTER,
DATE_OPTIONS,
DIM_OPTIONS,
EnumDataSourceType,
EnumModelDataType,
PARTITION_TIME_FORMATTER,
TYPE_OPTIONS,
} from '../constants';
import styles from '../style.less';

Expand Down Expand Up @@ -90,8 +90,7 @@ const ModelFieldForm: React.FC<Props> = ({
dataIndex: 'type',
width: 250,
render: (_: any, record: FieldItem) => {
const type = fields.find((field) => field.bizName === record.bizName)?.type;
const classType = fields.find((field) => field.bizName === record.bizName)?.classType;
const { type, classType } = record;
const selectTypeValue = [EnumModelDataType.DIMENSION].includes(classType)
? classType
: type;
Expand Down Expand Up @@ -229,13 +228,10 @@ const ModelFieldForm: React.FC<Props> = ({
);
}
if (type === EnumDataSourceType.MEASURES) {
const agg = record.expr
? fields.find((field) => field.expr === record.expr)?.agg
: undefined;
return (
<Select
placeholder="度量算子"
value={agg}
value={record.agg}
onChange={(value) => {
handleFieldChange(record, 'agg', value);
}}
Expand All @@ -251,7 +247,6 @@ const ModelFieldForm: React.FC<Props> = ({
</Select>
);
}

if (process.env.SHOW_TAG) {
if (type === EnumDataSourceType.CATEGORICAL) {
const isTag = fields.find((field) => field.bizName === record.bizName)?.isTag;
Expand Down Expand Up @@ -299,10 +294,7 @@ const ModelFieldForm: React.FC<Props> = ({
}
}
if ([EnumDataSourceType.TIME, EnumDataSourceType.PARTITION_TIME].includes(type)) {
const dateFormat = fields.find((field) => field.bizName === record.bizName)?.dateFormat;
const timeGranularity = fields.find(
(field) => field.bizName === record.bizName,
)?.timeGranularity;
const { dateFormat, timeGranularity } = record;
const dateFormatterOptions =
type === EnumDataSourceType.PARTITION_TIME ? PARTITION_TIME_FORMATTER : DATE_FORMATTER;

Expand Down

0 comments on commit e990b37

Please sign in to comment.