fix (接口定义): 优化操作历史查询缓慢问题

--bug=1007003 --user=赵勇 【github#6347】查询变更历史,出现慢查询,查询5分钟 才查出结果 https://www.tapd.cn/55049933/s/1058794
This commit is contained in:
fit2-zhao 2021-10-25 18:07:30 +08:00 committed by fit2-zhao
parent aff4b551f2
commit ed512308e5
14 changed files with 28 additions and 20 deletions

View File

@ -72,6 +72,12 @@
LEFT JOIN workspace w on t2.workspace_id = w.id
<where>
t.oper_type in ('UPDATE','BATCH_UPDATE')
<if test="request.modules != null and request.modules.size > 0 ">
and t.oper_module in
<foreach collection="request.modules" item="module" separator="," open="(" close=")">
#{module}
</foreach>
</if>
and t.oper_content is not null
<if test="request.sourceId != null and request.sourceId != ''">
and t.source_id like #{request.sourceId, jdbcType=VARCHAR}

View File

@ -30,9 +30,9 @@ public class OperatingLogController {
}
@GetMapping("/get/source/{id}")
public List<OperatingLogDTO> findBySourceId(@PathVariable String id) {
return operatingLogService.findBySourceId(id);
@PostMapping("/get/source")
public List<OperatingLogDTO> findBySourceId(@RequestBody OperatingLogRequest request) {
return operatingLogService.findBySourceId(request);
}
}

View File

@ -47,9 +47,8 @@ public class OperatingLogService {
return dto;
}
public List<OperatingLogDTO> findBySourceId(String id) {
OperatingLogRequest request = new OperatingLogRequest();
request.setSourceId("%" + id + "%");
public List<OperatingLogDTO> findBySourceId(OperatingLogRequest request) {
request.setSourceId("%" + request.getSourceId() + "%");
List<OperatingLogDTO> logWithBLOBs = extOperatingLogMapper.findBySourceId(request);
List<OperatingLogDTO> dtos = new ArrayList<>();
if (CollectionUtils.isNotEmpty(logWithBLOBs)) {

View File

@ -30,4 +30,6 @@ public class OperatingLogRequest implements Serializable {
private List<String> projectIds;
private List<String> modules;
}

View File

@ -451,4 +451,5 @@ SELECT id, follow_people
FROM test_case
WHERE follow_people IS NOT NULL AND follow_people != '';
ALTER TABLE test_case DROP COLUMN follow_people;
-- 操作日志类型增加普通索引
ALTER TABLE `operating_log` ADD INDEX oper_module_index ( `oper_module` );

View File

@ -865,7 +865,7 @@ export default {
})
},
openHis() {
this.$refs.changeHistory.open(this.currentScenario.id);
this.$refs.changeHistory.open(this.currentScenario.id, ["接口自动化", "Api automation", "接口自動化"]);
},
setModule(id, data) {
this.currentScenario.apiScenarioModuleId = id;

View File

@ -294,7 +294,7 @@ export default {
methods: {
hasPermission,
openHis(row) {
this.$refs.changeHistory.open(row.id);
this.$refs.changeHistory.open(row.id,["接口定义用例" , "接口定義用例" , "Api definition case"]);
},
handleRunBatch() {
this.$emit('batchRun');

View File

@ -80,7 +80,7 @@
},
methods: {
openHis(){
this.$refs.changeHistory.open(this.basisData.id);
this.$refs.changeHistory.open(this.basisData.id,["接口定义" , "接口定義" , "Api definition"]);
},
callback() {
this.validated = true;

View File

@ -254,7 +254,7 @@
},
methods: {
openHis(){
this.$refs.changeHistory.open(this.httpForm.id);
this.$refs.changeHistory.open(this.httpForm.id,["接口定义" , "接口定義" , "Api definition"]);
},
mockSetting() {
if(this.basisData.id){

View File

@ -80,7 +80,7 @@ export default {
},
methods: {
openHis(){
this.$refs.changeHistory.open(this.basisData.id);
this.$refs.changeHistory.open(this.basisData.id,["接口定义" , "接口定義" , "Api definition"]);
},
callback() {
this.validated = true;

View File

@ -143,7 +143,7 @@ export default {
},
methods: {
openHis(){
this.$refs.changeHistory.open(this.basisData.id);
this.$refs.changeHistory.open(this.basisData.id,["接口定义" , "接口定義" , "Api definition"]);
},
callback() {
this.validated = true;

View File

@ -74,8 +74,8 @@ export default {
handleClose() {
this.infoVisible = false;
},
getDetails(id) {
this.result = this.$get("/operating/log/get/source/" + id, response => {
getDetails(id, modules) {
this.result = this.$post("/operating/log/get/source/", {sourceId: id, modules: modules}, response => {
let data = response.data;
this.loading = false;
if (data) {
@ -83,17 +83,17 @@ export default {
}
})
},
open(id) {
open(id, modules) {
this.infoVisible = true;
this.loading = true;
this.getDetails(id);
this.getDetails(id, modules);
},
openDetail(row, value) {
value.createUser = row.details.createUser;
value.operTime = row.operTime;
if (value.columnName === "tags") {
this.$refs.tagsHistoryDetail.open(value);
} else if ((value.columnName === "request" || value.columnName === "response")&&
} else if ((value.columnName === "request" || value.columnName === "response") &&
(row.operModule === "接口定义" || row.operModule === "接口定義" || row.operModule === "Api definition")) {
this.$refs.apiHistoryDetail.open(value);
} else {

View File

@ -171,7 +171,7 @@ export default {
});
},
openHis() {
this.$refs.changeHistory.open(this.test.id);
this.$refs.changeHistory.open(this.test.id,["性能测试" , "性能測試" , "Performance test"]);
},
importAPITest() {
let apiTest = this.$store.state.test;

View File

@ -360,7 +360,7 @@
},
methods: {
openHis() {
this.$refs.changeHistory.open(this.form.id);
this.$refs.changeHistory.open(this.form.id,["测试用例" , "測試用例" , "Test case"]);
},
setModule(id, data) {
this.form.module = id;