mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 11:07:06 +00:00
Compare commits
9 Commits
90dcf09c8b
...
2f4f2027a5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f4f2027a5 | ||
|
|
47c2595fb8 | ||
|
|
9bddd4457e | ||
|
|
55ac3d1aa5 | ||
|
|
0427917624 | ||
|
|
d8fe2ed2b3 | ||
|
|
11d1264d38 | ||
|
|
32675387d7 | ||
|
|
e408204690 |
@@ -23,9 +23,11 @@ public class SqlExecuteReq {
|
||||
private Integer limit = 1000;
|
||||
|
||||
public String getSql() {
|
||||
if (StringUtils.isNotBlank(sql) && sql.endsWith(";")) {
|
||||
sql = sql.substring(0, sql.length() - 1);
|
||||
if(StringUtils.isNotBlank(sql)){
|
||||
sql=sql.replaceAll("^[\\n]+|[\\n]+$", "");
|
||||
sql=StringUtils.removeEnd(sql,";");
|
||||
}
|
||||
|
||||
return String.format(LIMIT_WRAPPER, sql, limit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public abstract class BaseMapper implements SchemaMapper {
|
||||
Map<MatchText, List<T>> matchResult = matchStrategy.match(chatQueryContext, terms,
|
||||
chatQueryContext.getRequest().getDataSetIds());
|
||||
List<T> matches = new ArrayList<>();
|
||||
if (Objects.isNull(matchResult)) {
|
||||
if (Objects.isNull(matchResult) || matchResult.isEmpty()) {
|
||||
return matches;
|
||||
}
|
||||
Optional<List<T>> first = matchResult.entrySet().stream()
|
||||
|
||||
@@ -88,7 +88,7 @@ public class SqlBuilder {
|
||||
GraphPath<String, DefaultEdge> selectedGraphPath = null;
|
||||
for (String fromModel : queryModels) {
|
||||
for (String toModel : queryModels) {
|
||||
if (fromModel != toModel) {
|
||||
if (!fromModel.equals(toModel)) {
|
||||
GraphPath<String, DefaultEdge> path = dijkstraAlg.getPath(fromModel, toModel);
|
||||
if (isGraphPathContainsAll(path, queryModels)) {
|
||||
selectedGraphPath = path;
|
||||
@@ -100,13 +100,13 @@ public class SqlBuilder {
|
||||
if (selectedGraphPath == null) {
|
||||
return dataModels;
|
||||
}
|
||||
Set<String> modelNames = Sets.newHashSet();
|
||||
Set<String> modelNames = Sets.newLinkedHashSet();
|
||||
for (DefaultEdge edge : selectedGraphPath.getEdgeList()) {
|
||||
modelNames.add(selectedGraphPath.getGraph().getEdgeSource(edge));
|
||||
modelNames.add(selectedGraphPath.getGraph().getEdgeTarget(edge));
|
||||
}
|
||||
return modelNames.stream().map(m -> ontology.getModelMap().get(m))
|
||||
.collect(Collectors.toSet());
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
private boolean isGraphPathContainsAll(GraphPath<String, DefaultEdge> graphPath,
|
||||
|
||||
@@ -109,9 +109,14 @@ public class MetricRepositoryImpl implements MetricRepository {
|
||||
}
|
||||
if (StringUtils.isNotBlank(metricFilter.getKey())) {
|
||||
String key = metricFilter.getKey();
|
||||
queryWrapper.lambda().like(MetricDO::getName, key).or().like(MetricDO::getBizName, key)
|
||||
.or().like(MetricDO::getDescription, key).or().like(MetricDO::getAlias, key)
|
||||
.or().like(MetricDO::getCreatedBy, key);
|
||||
queryWrapper.lambda()
|
||||
.and(wrapper -> wrapper
|
||||
.like(MetricDO::getName, key)
|
||||
.or().like(MetricDO::getBizName, key)
|
||||
.or().like(MetricDO::getDescription, key)
|
||||
.or().like(MetricDO::getAlias, key)
|
||||
.or().like(MetricDO::getCreatedBy, key)
|
||||
);
|
||||
}
|
||||
|
||||
return metricDOMapper.selectList(queryWrapper);
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@@ -50,10 +51,8 @@ public class DataSetController {
|
||||
|
||||
@GetMapping("/getDataSetList")
|
||||
public List<DataSetResp> getDataSetList(@RequestParam("domainId") Long domainId) {
|
||||
MetaFilter metaFilter = new MetaFilter();
|
||||
metaFilter.setDomainId(domainId);
|
||||
metaFilter.setStatus(StatusEnum.ONLINE.getCode());
|
||||
return dataSetService.getDataSetList(metaFilter);
|
||||
List<Integer> statuCodeList = Arrays.asList(StatusEnum.ONLINE.getCode(),StatusEnum.OFFLINE.getCode());
|
||||
return dataSetService.getDataSetList(domainId,statuCodeList);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
|
||||
@@ -20,6 +20,8 @@ public interface DataSetService {
|
||||
|
||||
List<DataSetResp> getDataSetList(MetaFilter metaFilter);
|
||||
|
||||
List<DataSetResp> getDataSetList(Long domainId ,List<Integer> statuCodesList);
|
||||
|
||||
void delete(Long id, User user);
|
||||
|
||||
Map<Long, List<Long>> getModelIdToDataSetIds(List<Long> dataSetIds, User user);
|
||||
|
||||
@@ -102,6 +102,20 @@ public class DataSetServiceImpl extends ServiceImpl<DataSetDOMapper, DataSetDO>
|
||||
return list(wrapper).stream().map(this::convert).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataSetResp> getDataSetList(Long domainId, List<Integer> statuCodesList) {
|
||||
if(domainId==null || CollectionUtils.isEmpty(statuCodesList)){
|
||||
return List.of();
|
||||
}
|
||||
QueryWrapper<DataSetDO> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(DataSetDO::getDomainId, domainId);
|
||||
wrapper.lambda().in(DataSetDO::getStatus, statuCodesList);
|
||||
wrapper.lambda().ne(DataSetDO::getStatus, StatusEnum.DELETED.getCode());
|
||||
|
||||
return list(wrapper).stream().map(this::convert).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id, User user) {
|
||||
DataSetDO dataSetDO = getById(id);
|
||||
|
||||
@@ -277,7 +277,7 @@ public class DictUtils {
|
||||
ModelResp model = modelService.getModel(dictItemResp.getModelId());
|
||||
String tableStr = StringUtils.isNotBlank(model.getModelDetail().getTableQuery())
|
||||
? model.getModelDetail().getTableQuery()
|
||||
: "(" + model.getModelDetail().getSqlQuery() + ")";
|
||||
: "(" + model.getModelDetail().getSqlQuery() + ") AS t";
|
||||
String sqlPattern =
|
||||
"select %s,count(1) from %s %s group by %s order by count(1) desc limit %d";
|
||||
String dimBizName = dictItemResp.getBizName();
|
||||
|
||||
@@ -420,4 +420,4 @@ ALTER TABLE s2_chat_model add column is_open tinyint DEFAULT NULL COMMENT '是
|
||||
ALTER TABLE s2_database add column is_open tinyint DEFAULT NULL COMMENT '是否公开';
|
||||
|
||||
--20250321
|
||||
ALTER TABLE s2_user add column last_loin datetime DEFAULT NULL;
|
||||
ALTER TABLE s2_user add column last_login datetime DEFAULT NULL;
|
||||
|
||||
@@ -416,11 +416,10 @@ const ChatItem: React.FC<Props> = ({
|
||||
|
||||
const onExportData = () => {
|
||||
const { queryColumns, queryResults } = data || {};
|
||||
if (!!queryResults) {
|
||||
if (!!queryResults && !!queryColumns) {
|
||||
const exportData = queryResults.map(item => {
|
||||
return Object.keys(item).reduce((result, key) => {
|
||||
const columnName = queryColumns?.find(column => column.nameEn === key)?.name || key;
|
||||
result[columnName] = item[key];
|
||||
return queryColumns.reduce((result, column) => {
|
||||
result[column.name || column.nameEn] = item[column.nameEn];
|
||||
return result;
|
||||
}, {});
|
||||
});
|
||||
|
||||
@@ -24,7 +24,6 @@ const Table: React.FC<Props> = ({ data, size, loading, question, onApplyAuth })
|
||||
dataIndex: bizName,
|
||||
key: bizName,
|
||||
title: name || bizName,
|
||||
defaultSortOrder: 'descend',
|
||||
sorter:
|
||||
showType === 'NUMBER'
|
||||
? (a, b) => {
|
||||
@@ -43,8 +42,8 @@ const Table: React.FC<Props> = ({ data, size, loading, question, onApplyAuth })
|
||||
{`${
|
||||
value
|
||||
? formatByDataFormatType(value, dataFormatType, dataFormat)
|
||||
: 0
|
||||
}%`}
|
||||
: '0%'
|
||||
}`}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -73,10 +72,11 @@ const Table: React.FC<Props> = ({ data, size, loading, question, onApplyAuth })
|
||||
return index % 2 !== 0 ? `${prefixCls}-even-row` : '';
|
||||
};
|
||||
|
||||
const dateColumn = queryColumns.find(column => column.type === 'DATE');
|
||||
const dateColumn = queryColumns.find(column => column.type === 'DATE' || column.showType === 'DATE');
|
||||
const dataSource = dateColumn
|
||||
? queryResults.sort((a, b) => moment(a[dateColumn.bizName]).diff(moment(b[dateColumn.bizName])))
|
||||
: queryResults;
|
||||
|
||||
return (
|
||||
<div className={prefixCls}>
|
||||
{question && (
|
||||
|
||||
Reference in New Issue
Block a user