diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/datacount/response/ApiDataCountDTO.java b/api-test/backend/src/main/java/io/metersphere/api/dto/datacount/response/ApiDataCountDTO.java index a016649295..ca790ff725 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/datacount/response/ApiDataCountDTO.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/datacount/response/ApiDataCountDTO.java @@ -28,7 +28,9 @@ public class ApiDataCountDTO { private long runningCount = 0; private long finishedCount = 0; private long notStartedCount = 0; + //本周执行次数 private long executedTimesInWeek = 0; + //历史执行总次数 private long executedCount = 0; private long notExecutedCount = 0; private long passCount = 0; @@ -119,6 +121,15 @@ public class ApiDataCountDTO { } } + /** + * 获取执行过的数据数 + * + * @return + */ + public long getExecutedData() { + return this.unPassCount + this.fakeErrorCount + this.passCount; + } + public void countApiCaseRunResult(List executeResultCountDTOList) { for (ExecuteResultCountDTO execResult : executeResultCountDTOList) { if (StringUtils.isEmpty(execResult.getExecResult())) { diff --git a/api-test/backend/src/main/java/io/metersphere/controller/home/ApiHomeController.java b/api-test/backend/src/main/java/io/metersphere/controller/home/ApiHomeController.java index d5a7609e4b..ac8dc08cf9 100644 --- a/api-test/backend/src/main/java/io/metersphere/controller/home/ApiHomeController.java +++ b/api-test/backend/src/main/java/io/metersphere/controller/home/ApiHomeController.java @@ -117,7 +117,7 @@ public class ApiHomeController { DecimalFormat coveredRateFormat = new DecimalFormat("0.0"); apiCountResult.setPassRate(coveredRateFormat.format(coveredRateNumber) + "%"); - float executedRateNumber = (float) apiCountResult.getExecutedCount() * 100 / apiCountResult.getTotal(); + float executedRateNumber = (float) apiCountResult.getExecutedData() * 100 / apiCountResult.getTotal(); DecimalFormat executedRateFormat = new DecimalFormat("0.0"); apiCountResult.setExecutedRate(executedRateFormat.format(executedRateNumber) + "%"); } else { @@ -137,6 +137,7 @@ public class ApiHomeController { apiCountResult.setCreatedInWeek(dateCountByCreateInThisWeek); long executedInThisWeekCountNumber = apiScenarioReportService.countByProjectIdAndCreateInThisWeek(projectId); apiCountResult.setExecutedTimesInWeek(executedInThisWeekCountNumber); + //所有执行次数 long executedCount = apiAutomationService.countExecuteTimesByProjectID(projectId, null); apiCountResult.setExecutedCount(executedCount); //未执行、未通过、已通过 @@ -148,7 +149,7 @@ public class ApiHomeController { float coveredRateNumber = (float) apiCountResult.getPassCount() * 100 / executedCount; apiCountResult.setPassRate(df.format(coveredRateNumber) + "%"); //执行率 - float executedRateNumber = (float) apiCountResult.getExecutedCount() * 100 / apiCountResult.getTotal(); + float executedRateNumber = (float) apiCountResult.getExecutedData() * 100 / apiCountResult.getTotal(); apiCountResult.setExecutedRate(df.format(executedRateNumber) + "%"); }