feat: 修复测试跟踪、接口测试首页针对接口案例的7天失败统计

修复测试跟踪、接口测试首页针对接口案例的7天失败统计:只统计定时任务与jenkins失败用例且在计划当中的数据
This commit is contained in:
song-tianyang 2021-05-31 15:19:17 +08:00 committed by 刘瑞斌
parent beb39ed41c
commit f27ff1e47d
2 changed files with 8 additions and 5 deletions

View File

@ -34,9 +34,10 @@
<select id="findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber" resultType="io.metersphere.api.dto.datacount.ExecutedCaseInfoResult"> <select id="findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber" resultType="io.metersphere.api.dto.datacount.ExecutedCaseInfoResult">
SELECT * FROM ( SELECT * FROM (
-- api_test_case 只查找测试计划执行的结果
SELECT testCase.testCaseID,testCase.testCaseName AS caseName,testCase.testPlanName AS testPlan ,caseErrorCountData.dataCountNumber AS failureTimes,'apiCase' AS caseType SELECT testCase.testCaseID,testCase.testCaseName AS caseName,testCase.testPlanName AS testPlan ,caseErrorCountData.dataCountNumber AS failureTimes,'apiCase' AS caseType
FROM ( FROM (
SELECT apiCase.id AS testCaseID,apiCase.`name` AS testCaseName,group_concat(testPlan.`name`) AS testPlanName, testPlanCase.update_time as updateTime SELECT testPlanCase.id AS testCaseID,apiCase.`name` AS testCaseName,group_concat(testPlan.`name`) AS testPlanName, testPlanCase.update_time as updateTime
FROM api_test_case apiCase FROM api_test_case apiCase
inner join api_definition on api_definition.id = apiCase.api_definition_id inner join api_definition on api_definition.id = apiCase.api_definition_id
INNER JOIN test_plan_api_case testPlanCase ON testPlanCase.api_case_id = apiCase.id INNER JOIN test_plan_api_case testPlanCase ON testPlanCase.api_case_id = apiCase.id
@ -46,11 +47,13 @@
ORDER BY apiCase.create_time DESC ORDER BY apiCase.create_time DESC
)testCase )testCase
INNER JOIN ( INNER JOIN (
SELECT resource_id AS testCaseID,COUNT(id) AS dataCountNumber,start_time AS executeTime FROM api_definition_exec_result SELECT resource_id AS testPlanCaseID,COUNT(id) AS dataCountNumber,start_time AS executeTime FROM api_definition_exec_result
WHERE resource_id IN ( WHERE resource_id IN (
SELECT id FROM api_test_case WHERE project_id = #{projectId} SELECT t2.id FROM api_test_case t1
INNER JOIN test_plan_api_case t2 ON t1.id = t2.api_case_id
WHERE t1.project_id = #{projectId}
) and `status` = 'error' GROUP BY resource_id ) and `status` = 'error' GROUP BY resource_id
) caseErrorCountData ON caseErrorCountData.testCaseID =testCase.testCaseID ) caseErrorCountData ON caseErrorCountData.testPlanCaseID =testCase.testCaseID
WHERE testCase.updateTime >= #{startTimestamp} WHERE testCase.updateTime >= #{startTimestamp}
UNION UNION
SELECT scene.id AS testCaseID,scene.`name` AS caseName,apiScene.testPlanName AS testPlan,count(report.id) AS failureTimes,'scenario' AS caseType SELECT scene.id AS testCaseID,scene.`name` AS caseName,apiScene.testPlanName AS testPlan,count(report.id) AS failureTimes,'scenario' AS caseType

View File

@ -221,7 +221,7 @@
AND p.id IN (SELECT test_plan_id FROM test_plan_api_scenario WHERE api_scenario_id = #{request.scenarioId} ) AND p.id IN (SELECT test_plan_id FROM test_plan_api_scenario WHERE api_scenario_id = #{request.scenarioId} )
</if> </if>
<if test="request.apiId != null"> <if test="request.apiId != null">
AND p.id IN (SELECT test_plan_id FROM test_plan_api_case WHERE api_case_id = #{request.apiId}) AND p.id IN (SELECT test_plan_id FROM test_plan_api_case WHERE id = #{request.apiId})
</if> </if>
<if test="request.loadId != null"> <if test="request.loadId != null">
AND p.id IN (SELECT test_plan_id FROM test_plan_load_case WHERE load_case_id = #{request.loadId}) AND p.id IN (SELECT test_plan_id FROM test_plan_load_case WHERE load_case_id = #{request.loadId})