This commit is contained in:
fit2-zhao 2020-12-21 19:28:25 +08:00
commit 045681c68a
3 changed files with 48 additions and 27 deletions

View File

@ -26,33 +26,54 @@
WHERE testCase.project_id = #{projectId}) WHERE testCase.project_id = #{projectId})
</select> </select>
<!-- <select id="findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber" resultType="io.metersphere.api.dto.dataCount.ExecutedCaseInfoResult">-->
<!-- SELECT * FROM (-->
<!-- SELECT testCase.testCaseName AS caseName,testCase.testPlanName AS testPlan ,caseErrorCountData.dataCountNumber AS failureTimes,'apiCase' AS caseType-->
<!-- FROM (-->
<!-- SELECT apiCase.id AS testCaseID,apiCase.`name` AS testCaseName,group_concat(testPlan.`name`) AS testPlanName FROM api_test_case apiCase-->
<!-- LEFT JOIN test_plan testPlan ON testPlan.api_ids like concat('%"',apiCase.id,'"%')-->
<!-- GROUP BY apiCase.id-->
<!-- ORDER BY apiCase.create_time DESC-->
<!-- )testCase-->
<!-- INNER JOIN (-->
<!-- SELECT resource_id AS testCaseID,COUNT(id) AS dataCountNumber,start_time AS executeTime FROM api_definition_exec_result-->
<!-- WHERE resource_id IN (-->
<!-- SELECT id FROM api_test_case WHERE project_id = #{projectId}-->
<!-- ) and `status` = 'error' GROUP BY resource_id-->
<!-- ) caseErrorCountData ON caseErrorCountData.testCaseID =testCase.testCaseID-->
<!-- WHERE caseErrorCountData.executeTime >= #{startTimestamp}-->
<!-- UNION-->
<!-- SELECT scene.`name` AS caseName,testPlan.`name` AS testPlan,count(report.id) AS failureTimes,'scenario' AS caseType-->
<!-- FROM api_scenario_report report-->
<!-- INNER JOIN api_scenario_report_detail reportDetail ON report.id = reportDetail.report_id-->
<!-- INNER JOIN api_scenario scene ON reportDetail.content like concat('%"',scene.`name`,'"%')-->
<!-- LEFT JOIN test_plan_api_scenario apiScene ON apiScene.api_scenario_id = scene.id-->
<!-- LEFT JOIN test_plan testPlan ON testPlan.id = apiScene.test_plan_id-->
<!-- WHERE report.project_id = #{projectId}-->
<!-- AND report.status = 'Error' AND report.create_time >= #{startTimestamp}-->
<!-- GROUP BY scene.id-->
<!-- ) showTable-->
<!-- ORDER BY showTable.failureTimes DESC-->
<!-- limit #{limitNumber}-->
<!-- </select>-->
<select id="findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber" resultType="io.metersphere.api.dto.dataCount.ExecutedCaseInfoResult"> <select id="findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber" resultType="io.metersphere.api.dto.dataCount.ExecutedCaseInfoResult">
SELECT * FROM ( SELECT * FROM (
SELECT testCase.testCaseName AS caseName,testCase.testPlanName AS testPlan ,caseErrorCountData.dataCountNumber AS failureTimes,'apiCase' AS caseType SELECT 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 FROM api_test_case apiCase SELECT apiCase.id AS testCaseID,apiCase.`name` AS testCaseName,group_concat(testPlan.`name`) AS testPlanName FROM api_test_case apiCase
LEFT JOIN test_plan testPlan ON testPlan.api_ids like concat('%"',apiCase.id,'"%') LEFT JOIN test_plan testPlan ON testPlan.api_ids like concat('%"',apiCase.id,'"%')
GROUP BY apiCase.id GROUP BY apiCase.id
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 testCaseID,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 id FROM api_test_case WHERE 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.testCaseID =testCase.testCaseID
WHERE caseErrorCountData.executeTime >= #{startTimestamp} WHERE caseErrorCountData.executeTime >= #{startTimestamp}
UNION ) showTable
SELECT scene.`name` AS caseName,testPlan.`name` AS testPlan,count(report.id) AS failureTimes,'scenario' AS caseType
FROM api_scenario_report report
INNER JOIN api_scenario_report_detail reportDetail ON report.id = reportDetail.report_id
INNER JOIN api_scenario scene ON reportDetail.content like concat('%"',scene.`name`,'"%')
LEFT JOIN test_plan_api_scenario apiScene ON apiScene.api_scenario_id = scene.id
LEFT JOIN test_plan testPlan ON testPlan.id = apiScene.test_plan_id
WHERE report.project_id = #{projectId}
AND report.status = 'Error' AND report.create_time >= #{startTimestamp}
GROUP BY scene.id
) showTable
ORDER BY showTable.failureTimes DESC ORDER BY showTable.failureTimes DESC
limit #{limitNumber} limit #{limitNumber}
</select> </select>

View File

@ -286,7 +286,7 @@
AND create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp} AND create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
</select> </select>
<select id="countApiCoverageByProjectID" resultType="io.metersphere.api.dto.dataCount.ApiDataCountResult"> <select id="countApiCoverageByProjectID" resultType="io.metersphere.api.dto.dataCount.ApiDataCountResult">
SELECT count(api.id) AS countNumber, if(test_case_api.api_definition_id is null,"coverage","uncoverage") AS groupField FROM api_definition api left Join ( SELECT count(api.id) AS countNumber, if(test_case_api.api_definition_id is null,"uncoverage","coverage") AS groupField FROM api_definition api left Join (
SELECT DISTINCT api_definition_id FROM api_test_case SELECT DISTINCT api_definition_id FROM api_test_case
) test_case_api ON api.id = test_case_api.api_definition_id ) test_case_api ON api.id = test_case_api.api_definition_id
WHERE api.project_id = #{0} WHERE api.project_id = #{0}

View File

@ -370,7 +370,7 @@ export default {
}); });
}, },
refresh() { refresh() {
this.condition = {components: TEST_CASE_CONFIGS}; // this.condition = {components: TEST_CASE_CONFIGS};
// this.selectIds.clear(); // this.selectIds.clear();
this.selectRows.clear(); this.selectRows.clear();
this.$emit('refresh'); this.$emit('refresh');