diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/CalculateUtils.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/CalculateUtils.java index b43c66d8cc..cac0d63feb 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/CalculateUtils.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/CalculateUtils.java @@ -22,4 +22,16 @@ public class CalculateUtils { return passRate + "%"; } } + + + public static double percentage(int numerator, int denominator) { + if (denominator == 0) { + return 0; + } + DecimalFormat rateFormat = new DecimalFormat("#0.00"); + rateFormat.setMinimumFractionDigits(2); + rateFormat.setMaximumFractionDigits(2); + + return Double.parseDouble(rateFormat.format((double) numerator * 100 / (double) denominator)); + } } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.java index 011532834d..34d934d408 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.java @@ -83,5 +83,5 @@ public interface ExtTestPlanApiCaseMapper { Integer countByPlanIds(@Param("planIds") List planIds); - List selectDistinctLastExecResultByTestPlanIds(@Param("testPlanIds") List testPlanIds); + List selectLastExecResultByTestPlanIds(@Param("testPlanIds") List testPlanIds); } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.xml b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.xml index fb131e935b..f7b5dd543d 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.xml +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.xml @@ -893,9 +893,9 @@ AND test_plan.status != 'ARCHIVED' - - -