mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-13 21:17:08 +00:00
* [improvement][semantic-fe] Added an editing component to set filtering rules for Q&A. Now, the SQL editor will be accompanied by a list for display and control, to resolve ambiguity when using comma-separated values. [improvement][semantic-fe] Improved validation logic and prompt copywriting for data source/dimension/metric editing and creation. [improvement][semantic-fe] Improved user experience for visual modeling. Now, when using the legend to control the display/hide of data sources and their associated metric dimensions, the canvas will be re-layout based on the activated data source in the legend. * [improvement][semantic-fe] Submitted a new version of the visual modeling tool. [improvement][semantic-fe] Fixed an issue with the initialization of YoY and MoM metrics in Q&A settings. [improvement][semantic-fe] Added a version field to the database settings. [improvement][semantic-fe] 1. Added the ability to set YoY and MoM metrics in Q&A settings.2. Moved dimension value editing from the dimension editing window to the dimension list. --------- Co-authored-by: tristanliu <tristanliu@tencent.com>
95 lines
2.3 KiB
TypeScript
95 lines
2.3 KiB
TypeScript
import { IChatConfig, ISemantic } from '../../data';
|
|
import { TransType } from '../../enum';
|
|
|
|
type FormatResult = IChatConfig.IChatRichConfig & {
|
|
chatDefaultConfig: {
|
|
dimensionIds: number[];
|
|
metricIds: number[];
|
|
};
|
|
};
|
|
export const formatRichEntityDataListToIds = (
|
|
entityData: IChatConfig.IChatRichConfig,
|
|
): FormatResult => {
|
|
if (!entityData?.chatDefaultConfig) {
|
|
return {} as FormatResult;
|
|
}
|
|
const { chatDefaultConfig, entity } = entityData;
|
|
|
|
const detailData: {
|
|
dimensionIds: number[];
|
|
metricIds: number[];
|
|
ratioMetricIds: number[];
|
|
} = { dimensionIds: [], metricIds: [], ratioMetricIds: [] };
|
|
const { dimensions, metrics, ratioMetrics } = chatDefaultConfig || {};
|
|
if (Array.isArray(dimensions)) {
|
|
detailData.dimensionIds = dimensions.map((item: ISemantic.IDimensionItem) => {
|
|
return item.id;
|
|
});
|
|
}
|
|
if (Array.isArray(metrics)) {
|
|
detailData.metricIds = metrics.map((item: ISemantic.IMetricItem) => {
|
|
return item.id;
|
|
});
|
|
}
|
|
if (Array.isArray(ratioMetrics)) {
|
|
detailData.ratioMetricIds = ratioMetrics.map((item: ISemantic.IMetricItem) => {
|
|
return item.id;
|
|
});
|
|
}
|
|
|
|
let entitySetting = {};
|
|
if (entity) {
|
|
const entityItem = entity.dimItem;
|
|
const entityId = entityItem?.id || null;
|
|
const names = entity.names || [];
|
|
entitySetting = {
|
|
entity: {
|
|
...entity,
|
|
entityId,
|
|
name: names.join(','),
|
|
},
|
|
};
|
|
}
|
|
|
|
return {
|
|
...entityData,
|
|
...entitySetting,
|
|
chatDefaultConfig: {
|
|
...chatDefaultConfig,
|
|
...detailData,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const wrapperTransTypeAndId = (exTransType: TransType, id: number) => {
|
|
return `${exTransType}-${id}`;
|
|
};
|
|
|
|
export const splitListToTransTypeId = (dataItemIds: string[]) => {
|
|
const idListMap = dataItemIds.reduce(
|
|
(
|
|
idMap: {
|
|
dimensionIds: number[];
|
|
metricIds: number[];
|
|
},
|
|
item: string,
|
|
) => {
|
|
const [transType, id] = item.split('-');
|
|
if (id) {
|
|
if (transType === TransType.DIMENSION) {
|
|
idMap.dimensionIds.push(Number(id));
|
|
}
|
|
if (transType === TransType.METRIC) {
|
|
idMap.metricIds.push(Number(id));
|
|
}
|
|
}
|
|
return idMap;
|
|
},
|
|
{
|
|
dimensionIds: [],
|
|
metricIds: [],
|
|
},
|
|
);
|
|
return idListMap;
|
|
};
|