diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/QueryAPIReportRequest.java b/api-test/backend/src/main/java/io/metersphere/api/dto/QueryAPIReportRequest.java index ade9a45604..40d0b6289a 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/QueryAPIReportRequest.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/QueryAPIReportRequest.java @@ -24,7 +24,7 @@ public class QueryAPIReportRequest { private Map combine; private String selectDataType; private String selectDataRange; - + private String versionId; /** * 查询哪种用例的报告 SCENARIO/API */ diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.java b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.java index af72a70917..cbc33f3f5e 100644 --- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.java +++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.java @@ -28,8 +28,7 @@ public interface ExtApiDefinitionExecResultMapper { long countByTestCaseIDInProject(String projectId); - List findFailureCaseInTestPlanByProjectIDAndExecuteTimeAndLimitNumber(@Param("projectId") String projectId, @Param("selectFunctionCase") boolean selectFunctionCase, - @Param("startTimestamp") long startTimestamp, @Param("limitNumber") int limitNumber); + List findFailureCaseInTestPlanByProjectIDAndExecuteTimeAndLimitNumber(@Param("projectId") String projectId, @Param("version") String version, @Param("selectFunctionCase") boolean selectFunctionCase, @Param("startTimestamp") long startTimestamp, @Param("limitNumber") int limitNumber); String selectExecResult(String resourceId); diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml index c493042de7..40d7896cad 100644 --- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml +++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml @@ -77,7 +77,8 @@ INNER JOIN test_plan testPlan ON testPlan.id = testPlanCase.test_plan_id WHERE ( (apiCase.`status` IS NULL OR apiCase.`status` != 'Trash') - AND apiCase.project_id = #{projectId})) testCase + AND apiCase.project_id = #{projectId} + )) testCase INNER JOIN (SELECT executionInfo.source_id AS sourceId, COUNT(executionInfo.id) AS dataCountNumber FROM api_case_execution_info executionInfo @@ -85,6 +86,9 @@ ON executionInfo.source_id = testPlanCase.id WHERE executionInfo.`result` = 'ERROR' AND executionInfo.create_time > #{startTimestamp} + + AND executionInfo.version = #{versionId} + GROUP BY source_id) caseErrorCountData ON caseErrorCountData.sourceId = testCase.testPlanCaseID UNION @@ -110,6 +114,9 @@ AND scene.`status` != 'Trash' AND ( executionInfo.result = 'ERROR' ) AND executionInfo.create_time >= #{startTimestamp} + + AND executionInfo.version = #{versionId} + GROUP BY scene.id,apiScene.testPlanId diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java index 62f5d0bb63..2a7e0d27c5 100644 --- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java +++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java @@ -39,13 +39,13 @@ public interface ExtApiDefinitionMapper { int reduction(@Param("ids") List ids); - List countProtocolByProjectID(String projectId); + List countProtocolByProjectID(@Param("projectId") String projectId, @Param("versionId") String versionId); - Long countByProjectIDAndCreateInThisWeek(@Param("projectId") String projectId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp); + Long countByProjectIDAndCreateInThisWeek(@Param("projectId") String projectId, @Param("versionId") String versionId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp); - List countStateByProjectID(String projectId); + List countStateByProjectID(@Param("projectId") String projectId, @Param("versionId") String versionId); - List countApiCoverageByProjectID(String projectId); + List countApiCoverageByProjectID(@Param("projectId") String projectId, @Param("versionId") String versionId); ApiDefinition getNextNum(@Param("projectId") String projectId); @@ -55,7 +55,7 @@ public interface ExtApiDefinitionMapper { List selectIds(@Param("request") BaseQueryRequest query); - List selectEffectiveIdByProjectId(String projectId); + List selectEffectiveIdByProjectId(@Param("projectId") String projectId, @Param("versionId") String versionId); List listByIds(@Param("ids") List ids); @@ -73,7 +73,7 @@ public interface ExtApiDefinitionMapper { Long getLastOrder(@Param("projectId") String projectId, @Param("baseOrder") Long baseOrder); - long countApiByProjectIdAndHasCase(String projectId); + long countApiByProjectIdAndHasCase(@Param("projectId") String projectId, @Param("versionId") String versionId); List getForGraph(@Param("ids") Set ids); @@ -99,7 +99,7 @@ public interface ExtApiDefinitionMapper { int countById(String id); - List selectEffectiveIdByProjectIdAndHaveNotCase(String projectId); + List selectEffectiveIdByProjectIdAndHaveNotCase(@Param("projectId") String projectId, @Param("versionId") String versionId); int deleteApiToGc(ApiDefinitionRequest request); diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml index 4fdb511677..c4d75a6b1b 100644 --- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml +++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml @@ -398,16 +398,27 @@ select id, path, method, protocol from api_definition - WHERE project_id = #{0} - AND status != 'Trash' AND latest = 1 + WHERE project_id = #{projectId} + AND status != 'Trash' + + AND version_id = #{versionId} + + + AND latest = 1 + SELECT COUNT(id) FROM api_definition - WHERE project_id = #{0} + WHERE project_id = #{projectId} AND `status` != 'Trash' AND id IN ( SELECT api_definition_id FROM api_test_case WHERE `status` is null or `status` != 'Trash' ) - AND latest = 1 + + AND version_id = #{versionId} + + + AND latest = 1 + SELECT COUNT(DISTINCT ref_id) AS countNumber FROM api_scenario - WHERE project_id = #{0} - AND status != 'Trash' AND latest = 1 + WHERE project_id = #{projectId} + AND status != 'Trash' + + AND version_id = #{versionId} + + + AND latest = 1 + @@ -552,8 +564,14 @@ diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReferenceIdMapper.java b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReferenceIdMapper.java index 29e96d4328..090c3ae220 100644 --- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReferenceIdMapper.java +++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReferenceIdMapper.java @@ -1,11 +1,12 @@ package io.metersphere.base.mapper.ext; import io.metersphere.base.domain.ApiScenarioReferenceId; +import org.apache.ibatis.annotations.Param; import java.util.List; public interface ExtApiScenarioReferenceIdMapper { - List selectUrlByProjectId(String projectId); + List selectUrlByProjectId(@Param("projectId") String projectId, @Param("versionId") String versionId); List selectReferenceIdByIds(List ids); } diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReferenceIdMapper.xml b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReferenceIdMapper.xml index b45cded606..0e638fd60c 100644 --- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReferenceIdMapper.xml +++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReferenceIdMapper.xml @@ -4,12 +4,17 @@ SELECT * FROM `schedule` WHERE resource_id IN ( - SELECT id FROM api_scenario WHERE project_id = #{0,jdbcType=VARCHAR} AND status != 'Trash' AND latest = 1 + SELECT id FROM api_scenario WHERE project_id = #{projectId,jdbcType=VARCHAR} AND status != 'Trash' + + AND version_id = #{versionId} + + + AND latest = 1 + ) + + + update schedule set name = #{name} where resource_id = #{resourceId} diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/BaseScheduleService.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/BaseScheduleService.java index b3382f3af4..6bc39ec6df 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/BaseScheduleService.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/BaseScheduleService.java @@ -221,11 +221,12 @@ public class BaseScheduleService { }); } - public List selectScenarioTaskByProjectId(String projectId) { - return baseScheduleMapper.selectScenarioTaskByProjectId(projectId); + public List selectScenarioTaskByProjectId(String projectId, String versionId) { + return baseScheduleMapper.selectScenarioTaskByProjectId(projectId, versionId); } - public long countTaskByProjectIdInThisWeek(String projectId) { + + public long countTaskByProjectIdInThisWeek(String projectId, String versionId) { Map startAndEndDateInWeek = DateUtils.getWeedFirstTimeAndLastTime(new Date()); Date firstTime = startAndEndDateInWeek.get("firstTime"); @@ -234,7 +235,7 @@ public class BaseScheduleService { if (firstTime == null || lastTime == null) { return 0; } else { - return baseScheduleMapper.countTaskByProjectIdAndCreateTimeRange(projectId, firstTime.getTime(), lastTime.getTime()); + return baseScheduleMapper.countTaskByProjectIdAndCreateTimeRange(projectId, versionId, firstTime.getTime(), lastTime.getTime()); } } diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/task/service/TaskService.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/task/service/TaskService.java index 82eb15d6c3..8451604e8a 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/task/service/TaskService.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/task/service/TaskService.java @@ -167,4 +167,8 @@ public class TaskService { } return false; } + + public List findScenarioAndSwaggerRunningTaskInfoByProjectID(String projectId, String versionId) { + return baseScheduleMapper.findScenarioAndSwaggerRunningTaskInfoByProjectID(projectId, versionId); + } } diff --git a/test-track/frontend/src/api/remote/api/api-home.js b/test-track/frontend/src/api/remote/api/api-home.js index bb8aac2660..6925515ac1 100644 --- a/test-track/frontend/src/api/remote/api/api-home.js +++ b/test-track/frontend/src/api/remote/api/api-home.js @@ -1,7 +1,16 @@ -import {post, get} from "@/business/utils/sdk-utils"; +import { get } from "@/business/utils/sdk-utils"; -const BASE_URL = '/home/'; +const BASE_URL = "/home/"; -export function homeTestPlanFailureCaseGet(projectId, selectFunctionCase, limitNumber, currentPage, pageSize) { - return get(BASE_URL + `failure/case/about/plan/${projectId}/${selectFunctionCase}/${limitNumber}/${currentPage}/${pageSize}`); +export function homeTestPlanFailureCaseGet( + projectId, + selectFunctionCase, + limitNumber, + currentPage, + pageSize +) { + return get( + BASE_URL + + `failure/case/about/plan/${projectId}/default/${selectFunctionCase}/${limitNumber}/${currentPage}/${pageSize}` + ); }