mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 11:07:06 +00:00
(improvement)(chat) async save time statistic and update parse info (#264)
Co-authored-by: jolunoluo
This commit is contained in:
@@ -7,5 +7,5 @@ import java.util.List;
|
|||||||
|
|
||||||
public interface StatisticsRepository {
|
public interface StatisticsRepository {
|
||||||
|
|
||||||
boolean batchSaveStatistics(List<StatisticsDO> list);
|
void batchSaveStatistics(List<StatisticsDO> list);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,9 @@ public class StatisticsRepositoryImpl implements StatisticsRepository {
|
|||||||
this.statisticsMapper = statisticsMapper;
|
this.statisticsMapper = statisticsMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean batchSaveStatistics(List<StatisticsDO> list) {
|
public void batchSaveStatistics(List<StatisticsDO> list) {
|
||||||
return statisticsMapper.batchSaveStatistics(list);
|
statisticsMapper.batchSaveStatistics(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ import com.tencent.supersonic.chat.persistence.dataobject.StatisticsDO;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface StatisticsService {
|
public interface StatisticsService {
|
||||||
boolean batchSaveStatistics(List<StatisticsDO> list);
|
void batchSaveStatistics(List<StatisticsDO> list);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import com.tencent.supersonic.common.util.JsonUtil;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.compress.utils.Lists;
|
import org.apache.commons.compress.utils.Lists;
|
||||||
import org.springframework.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.tencent.supersonic.chat.persistence.dataobject.StatisticsDO;
|
|||||||
import com.tencent.supersonic.chat.persistence.repository.StatisticsRepository;
|
import com.tencent.supersonic.chat.persistence.repository.StatisticsRepository;
|
||||||
import com.tencent.supersonic.chat.service.StatisticsService;
|
import com.tencent.supersonic.chat.service.StatisticsService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -18,8 +19,9 @@ public class StatisticsServiceImpl implements StatisticsService {
|
|||||||
this.statisticsRepository = statisticsRepository;
|
this.statisticsRepository = statisticsRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
@Override
|
@Override
|
||||||
public boolean batchSaveStatistics(List<StatisticsDO> list) {
|
public void batchSaveStatistics(List<StatisticsDO> list) {
|
||||||
return statisticsRepository.batchSaveStatistics(list);
|
statisticsRepository.batchSaveStatistics(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
<update id="updateParseInfo" parameterType="com.tencent.supersonic.chat.persistence.dataobject.ChatParseDO">
|
<update id="updateParseInfo" parameterType="com.tencent.supersonic.chat.persistence.dataobject.ChatParseDO">
|
||||||
update s2_chat_parse
|
update s2_chat_parse
|
||||||
set parse_info = #{parseInfo}
|
set parse_info = #{parseInfo}
|
||||||
where parse_id = #{parseId}
|
where question_id = #{questionId} and parse_id = #{parseId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="getParseInfo" resultMap="ChatParse">
|
<select id="getParseInfo" resultMap="ChatParse">
|
||||||
|
|||||||
@@ -4,11 +4,13 @@ import org.springframework.boot.SpringApplication;
|
|||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
|
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
|
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
|
||||||
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
@SpringBootApplication(scanBasePackages = {"com.tencent.supersonic"},
|
@SpringBootApplication(scanBasePackages = {"com.tencent.supersonic"},
|
||||||
exclude = {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class})
|
exclude = {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class})
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
|
@EnableAsync
|
||||||
public class StandaloneLauncher {
|
public class StandaloneLauncher {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class DatabaseServiceImpl implements DatabaseService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteDatabase(Long databaseId) {
|
public void deleteDatabase(Long databaseId) {
|
||||||
List<DatasourceResp> datasourceResps = datasourceService.getDatasourceList(databaseId);
|
List<DatasourceResp> datasourceResps = datasourceService.getDatasourceByDatabase(databaseId);
|
||||||
if (!CollectionUtils.isEmpty(datasourceResps)) {
|
if (!CollectionUtils.isEmpty(datasourceResps)) {
|
||||||
List<String> datasourceNames = datasourceResps.stream()
|
List<String> datasourceNames = datasourceResps.stream()
|
||||||
.map(DatasourceResp::getName).collect(Collectors.toList());
|
.map(DatasourceResp::getName).collect(Collectors.toList());
|
||||||
|
|||||||
@@ -261,6 +261,11 @@ public class DatasourceServiceImpl implements DatasourceService {
|
|||||||
return DatasourceConverter.convertList(datasourceRepository.getDatasourceList());
|
return DatasourceConverter.convertList(datasourceRepository.getDatasourceList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DatasourceResp> getDatasourceByDatabase(Long databaseId) {
|
||||||
|
return DatasourceConverter.convertList(datasourceRepository.getDatasourceByDatabase(databaseId));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DatasourceResp> getDatasourceListNoMeasurePrefix(Long modelId) {
|
public List<DatasourceResp> getDatasourceListNoMeasurePrefix(Long modelId) {
|
||||||
List<DatasourceResp> datasourceResps = getDatasourceList(modelId);
|
List<DatasourceResp> datasourceResps = getDatasourceList(modelId);
|
||||||
|
|||||||
@@ -28,13 +28,15 @@ public interface DatasourceService {
|
|||||||
|
|
||||||
List<DatasourceResp> getDatasourceList(Long modelId);
|
List<DatasourceResp> getDatasourceList(Long modelId);
|
||||||
|
|
||||||
|
List<DatasourceResp> getDatasourceByDatabase(Long databaseId);
|
||||||
|
|
||||||
Map<Long, DatasourceResp> getDatasourceMap();
|
Map<Long, DatasourceResp> getDatasourceMap();
|
||||||
|
|
||||||
void deleteDatasource(Long id) throws Exception;
|
void deleteDatasource(Long id) throws Exception;
|
||||||
|
|
||||||
DatasourceRelaResp createOrUpdateDatasourceRela(DatasourceRelaReq datasourceRelaReq, User user);
|
DatasourceRelaResp createOrUpdateDatasourceRela(DatasourceRelaReq datasourceRelaReq, User user);
|
||||||
|
|
||||||
List<DatasourceRelaResp> getDatasourceRelaList(Long domainId);
|
List<DatasourceRelaResp> getDatasourceRelaList(Long modelId);
|
||||||
|
|
||||||
void deleteDatasourceRela(Long id);
|
void deleteDatasourceRela(Long id);
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ public interface DatasourceRepository {
|
|||||||
|
|
||||||
List<DatasourceDO> getDatasourceList(Long modelId);
|
List<DatasourceDO> getDatasourceList(Long modelId);
|
||||||
|
|
||||||
|
List<DatasourceDO> getDatasourceByDatabase(Long databaseId);
|
||||||
|
|
||||||
DatasourceDO getDatasourceById(Long id);
|
DatasourceDO getDatasourceById(Long id);
|
||||||
|
|
||||||
void deleteDatasource(Long id);
|
void deleteDatasource(Long id);
|
||||||
|
|||||||
@@ -150,26 +150,26 @@ public class DatasourceConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static boolean isCraeteDimension(Dim dim) {
|
private static boolean isCreateDimension(Dim dim) {
|
||||||
return dim.getIsCreateDimension() == 1
|
return dim.getIsCreateDimension() == 1
|
||||||
&& StringUtils.isNotBlank(dim.getName())
|
&& StringUtils.isNotBlank(dim.getName())
|
||||||
&& !dim.getType().equalsIgnoreCase("time");
|
&& !dim.getType().equalsIgnoreCase("time");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isCraeteMetric(Measure measure) {
|
private static boolean isCreateMetric(Measure measure) {
|
||||||
return measure.getIsCreateMetric() == 1
|
return measure.getIsCreateMetric() == 1
|
||||||
&& StringUtils.isNotBlank(measure.getName());
|
&& StringUtils.isNotBlank(measure.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Dim> getDimToCreateDimension(Datasource datasource) {
|
public static List<Dim> getDimToCreateDimension(Datasource datasource) {
|
||||||
return datasource.getDatasourceDetail().getDimensions().stream()
|
return datasource.getDatasourceDetail().getDimensions().stream()
|
||||||
.filter(DatasourceConverter::isCraeteDimension)
|
.filter(DatasourceConverter::isCreateDimension)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Measure> getMeasureToCreateMetric(Datasource datasource) {
|
public static List<Measure> getMeasureToCreateMetric(Datasource datasource) {
|
||||||
return datasource.getDatasourceDetail().getMeasures().stream()
|
return datasource.getDatasourceDetail().getMeasures().stream()
|
||||||
.filter(DatasourceConverter::isCraeteMetric)
|
.filter(DatasourceConverter::isCreateMetric)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,13 @@ public class DatasourceRepositoryImpl implements DatasourceRepository {
|
|||||||
return datasourceMapper.selectByExampleWithBLOBs(datasourceExample);
|
return datasourceMapper.selectByExampleWithBLOBs(datasourceExample);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DatasourceDO> getDatasourceByDatabase(Long databaseId) {
|
||||||
|
DatasourceDOExample datasourceExample = new DatasourceDOExample();
|
||||||
|
datasourceExample.createCriteria().andDatabaseIdEqualTo(databaseId);
|
||||||
|
return datasourceMapper.selectByExampleWithBLOBs(datasourceExample);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatasourceDO getDatasourceById(Long id) {
|
public DatasourceDO getDatasourceById(Long id) {
|
||||||
return datasourceMapper.selectByPrimaryKey(id);
|
return datasourceMapper.selectByPrimaryKey(id);
|
||||||
|
|||||||
Reference in New Issue
Block a user