perf(接口测试): 接口自动化(回收站)删除功能的相关优化
--user=郭雨琦 原来删除一条场景要3s及以上,10条删除要20多s,现在将删除功能的时间缩短置3s左右
This commit is contained in:
parent
5af3371b75
commit
4929be575d
File diff suppressed because one or more lines are too long
|
@ -52,6 +52,12 @@ public class ApiScenarioReferenceIdService {
|
|||
apiScenarioReferenceIdMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public void deleteByScenarioIds(List<String> scenarioIds) {
|
||||
ApiScenarioReferenceIdExample example = new ApiScenarioReferenceIdExample();
|
||||
example.createCriteria().andApiScenarioIdIn(scenarioIds);
|
||||
apiScenarioReferenceIdMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public void saveApiAndScenarioRelation(ApiScenarioWithBLOBs scenario) {
|
||||
if (scenario.getId() == null) {
|
||||
return;
|
||||
|
|
|
@ -636,16 +636,7 @@ public class ApiScenarioReportService {
|
|||
ids.removeAll(reportRequest.getUnSelectIds());
|
||||
}
|
||||
}
|
||||
ApiScenarioReportExample example = new ApiScenarioReportExample();
|
||||
example.createCriteria().andIdIn(reportRequest.getIds());
|
||||
List<ApiScenarioReport> reportList = apiScenarioReportMapper.selectByExample(example);
|
||||
// 取出可能是集成报告的ID 放入删除
|
||||
reportList.forEach(item -> {
|
||||
List<String> reportIds = getReportIds(item.getScenarioId());
|
||||
if (CollectionUtils.isNotEmpty(reportIds)) {
|
||||
reportRequest.getIds().addAll(reportIds);
|
||||
}
|
||||
});
|
||||
|
||||
List<String> myList = reportRequest.getIds().stream().distinct().collect(Collectors.toList());
|
||||
reportRequest.setIds(myList);
|
||||
//为预防数量太多,调用删除方法时引起SQL过长的Bug,此处采取分批执行的方式。
|
||||
|
|
|
@ -11,7 +11,7 @@ public interface ApiScenarioMapper {
|
|||
|
||||
int deleteByExample(ApiScenarioExample example);
|
||||
|
||||
int deleteByPrimaryKey(String id);
|
||||
int deleteByPrimaryKey(String id);
|
||||
|
||||
int insert(ApiScenarioWithBLOBs record);
|
||||
|
||||
|
|
|
@ -53,6 +53,8 @@ public interface ExtApiScenarioMapper {
|
|||
|
||||
List<ApiScenarioWithBLOBs> listWithIds(@Param("ids") List<String> ids);
|
||||
|
||||
List<ApiScenarioWithBLOBs> listWithRefIds(@Param("ids") List<String> ids);
|
||||
|
||||
List<Map<String, Object>> listModuleByCollection(@Param("request") ApiScenarioRequest request);
|
||||
|
||||
String selectNameById(String id);
|
||||
|
|
|
@ -705,4 +705,12 @@
|
|||
WHERE version_id = #{versionId} AND project_id = #{projectId}
|
||||
) AND project_id = #{projectId}
|
||||
</select>
|
||||
<select id="listWithRefIds" resultType="io.metersphere.base.domain.ApiScenarioWithBLOBs">
|
||||
select id, project_id, version_id, scenario_definition, ref_id from api_scenario where ref_id in (
|
||||
select distinct ref_id from api_scenario where id in
|
||||
<foreach collection="ids" item="v" separator="," open="(" close=")">
|
||||
#{v}
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -256,3 +256,54 @@ CREATE PROCEDURE schema_change_api_one() BEGIN
|
|||
END//
|
||||
DELIMITER ;
|
||||
CALL schema_change_api_one();
|
||||
|
||||
|
||||
DROP PROCEDURE IF EXISTS schema_change_plan;
|
||||
DELIMITER //
|
||||
CREATE PROCEDURE schema_change_plan() BEGIN
|
||||
DECLARE CurrentDatabase VARCHAR(100);
|
||||
SELECT DATABASE() INTO CurrentDatabase;
|
||||
IF NOT EXISTS (SELECT * FROM information_schema.statistics WHERE table_schema=CurrentDatabase AND table_name = 'test_plan_api_scenario' AND index_name = 'api_scenario_id_index') THEN
|
||||
ALTER TABLE `test_plan_api_scenario` ADD INDEX api_scenario_id_index ( `api_scenario_id` );
|
||||
END IF;
|
||||
END//
|
||||
DELIMITER ;
|
||||
CALL schema_change_plan();
|
||||
|
||||
|
||||
DROP PROCEDURE IF EXISTS schema_change_scenario_one;
|
||||
DELIMITER //
|
||||
CREATE PROCEDURE schema_change_scenario_one() BEGIN
|
||||
DECLARE CurrentDatabase VARCHAR(100);
|
||||
SELECT DATABASE() INTO CurrentDatabase;
|
||||
IF NOT EXISTS (SELECT * FROM information_schema.statistics WHERE table_schema=CurrentDatabase AND table_name = 'api_scenario_report' AND index_name = 'scenario_id_index') THEN
|
||||
ALTER TABLE `api_scenario_report` ADD INDEX scenario_id_index ( `scenario_id` );
|
||||
END IF;
|
||||
END//
|
||||
DELIMITER ;
|
||||
CALL schema_change_scenario_one();
|
||||
|
||||
|
||||
DROP PROCEDURE IF EXISTS schema_change_rela_one;
|
||||
DELIMITER //
|
||||
CREATE PROCEDURE schema_change_rela_one() BEGIN
|
||||
DECLARE CurrentDatabase VARCHAR(100);
|
||||
SELECT DATABASE() INTO CurrentDatabase;
|
||||
IF NOT EXISTS (SELECT * FROM information_schema.statistics WHERE table_schema=CurrentDatabase AND table_name = 'relationship_edge' AND index_name = 'source_id_index') THEN
|
||||
ALTER TABLE `relationship_edge` ADD INDEX source_id_index ( `source_id` );
|
||||
END IF;
|
||||
END//
|
||||
DELIMITER ;
|
||||
CALL schema_change_rela_one();
|
||||
|
||||
DROP PROCEDURE IF EXISTS schema_change_rela_two;
|
||||
DELIMITER //
|
||||
CREATE PROCEDURE schema_change_rela_two() BEGIN
|
||||
DECLARE CurrentDatabase VARCHAR(100);
|
||||
SELECT DATABASE() INTO CurrentDatabase;
|
||||
IF NOT EXISTS (SELECT * FROM information_schema.statistics WHERE table_schema=CurrentDatabase AND table_name = 'relationship_edge' AND index_name = 'target_id_index') THEN
|
||||
ALTER TABLE `relationship_edge` ADD INDEX target_id_index ( `target_id` );
|
||||
END IF;
|
||||
END//
|
||||
DELIMITER ;
|
||||
CALL schema_change_rela_two();
|
Loading…
Reference in New Issue