This commit is contained in:
fit2-zhao 2020-12-24 14:57:16 +08:00
commit 8a665244a0
5 changed files with 21 additions and 14 deletions

View File

@ -204,13 +204,10 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
}
}
ApiScenarioReport savedReport = apiScenarioReportService.get(testId);
String scenarioID = null;
String scenarioID = "";
if(savedReport!=null){
scenarioID = savedReport.getScenarioId();
}
if(scenarioID==null){
scenarioID = apiScenarioReportService.getApiScenarioId(scenaName, scenarioReport.getProjectId());
}
testResult.setTestId(scenarioID);
} else {

View File

@ -88,7 +88,18 @@ public class ApiDefinitionExecResultService {
if (startTime == null) {
return new ArrayList<>(0);
} else {
return extApiDefinitionExecResultMapper.findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber(projectId, startTime.getTime(), limitNumber);
List<ExecutedCaseInfoResult>list = extApiDefinitionExecResultMapper.findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber(projectId, startTime.getTime());
List<ExecutedCaseInfoResult> returnList = new ArrayList<>(limitNumber);
for(int i = 0;i<list.size();i++){
if(i<limitNumber){
returnList.add(list.get(i));
}else {
break;
}
}
return returnList;
}
}
}

View File

@ -19,6 +19,6 @@ public interface ExtApiDefinitionExecResultMapper {
long countByTestCaseIDInProject(String projectId);
List<ExecutedCaseInfoResult> findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber(@Param("projectId") String projectId, @Param("startTimestamp") long startTimestamp, @Param("limitNumber") int limitNumber);
List<ExecutedCaseInfoResult> findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber(@Param("projectId") String projectId, @Param("startTimestamp") long startTimestamp);
}

View File

@ -52,9 +52,9 @@
UNION
SELECT scene.`name` AS caseName,apiScene.testPlanName 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 report.scenario_id = scene.id
LEFT JOIN
INNER JOIN api_scenario_report_detail reportDetail ON report.id = reportDetail.report_id
INNER JOIN api_scenario scene ON report.scenario_id = scene.id
LEFT JOIN
(
SELECT
apiScene.api_scenario_id,
@ -65,10 +65,9 @@
GROUP BY apiScene.api_scenario_id
)apiScene ON apiScene.api_scenario_id = scene.id
WHERE report.project_id = #{projectId}
AND report.status = 'Error' AND report.create_time >= #{startTimestamp}
GROUP BY scene.id
AND ( report.STATUS = 'Error' OR report.STATUS = 'Fail' ) AND report.create_time >= #{startTimestamp}
GROUP BY scene.id
) showTable
ORDER BY showTable.failureTimes DESC
limit #{limitNumber}
</select>
</mapper>

View File

@ -115,11 +115,11 @@
</update>
<select id="countByProjectID" resultType="java.lang.Long">
SELECT COUNT(id) AS countNumber FROM api_scenario WHERE project_id = #{0}
SELECT COUNT(id) AS countNumber FROM api_scenario WHERE project_id = #{0} AND status != 'Trash'
</select>
<select id="countByProjectIDAndCreatInThisWeek" resultType="java.lang.Long">
SELECT count(id) AS countNumber FROM api_scenario
WHERE project_id = #{projectId}
WHERE project_id = #{projectId} AND status != 'Trash'
AND create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
</select>