fix(接口测试): 修复接口测试首页数量不能对应的问题

This commit is contained in:
CaptainB 2022-01-25 16:17:07 +08:00 committed by zhangdahai112
parent 3ec8b61e60
commit 17da33c464
6 changed files with 18 additions and 11 deletions

View File

@ -1780,7 +1780,7 @@ public class ApiDefinitionService {
return 0;
} else {
ApiDefinitionExample example = new ApiDefinitionExample();
example.createCriteria().andProjectIdEqualTo(projectId).andStatusNotEqualTo("Trash");
example.createCriteria().andProjectIdEqualTo(projectId).andStatusNotEqualTo("Trash").andLatestEqualTo(true);
return apiDefinitionMapper.countByExample(example);
}
}

View File

@ -344,7 +344,12 @@
</update>
<select id="countProtocolByProjectID" resultType="io.metersphere.api.dto.datacount.ApiDataCountResult">
SELECT protocol AS groupField,count(DISTINCT ref_id) AS countNumber FROM api_definition WHERE project_id = #{0} AND `status` != 'Trash' GROUP BY protocol
SELECT protocol AS groupField,count(DISTINCT ref_id) AS countNumber
FROM api_definition
WHERE project_id = #{0}
AND `status` != 'Trash'
AND latest = 1
GROUP BY protocol
</select>
<select id="countStateByProjectID" resultType="io.metersphere.api.dto.datacount.ApiDataCountResult">
SELECT status AS groupField,count(id) AS countNumber FROM api_definition WHERE project_id = #{0} AND `status` != 'Trash' GROUP BY status
@ -591,7 +596,7 @@
<select id="selectEffectiveIdByProjectId" resultType="io.metersphere.base.domain.ApiDefinition">
select id,path,method
from api_definition
WHERE project_id = #{0} AND status != 'Trash' AND protocol = 'HTTP'
WHERE project_id = #{0} AND status != 'Trash' AND protocol = 'HTTP' AND latest = 1
</select>
<select id="moduleCount" resultType="java.lang.Integer">
@ -826,6 +831,7 @@
SELECT api_definition_id FROM api_test_case WHERE `status` is null or `status` != 'Trash'
)
)
AND latest = 1
</select>
<select id="getForGraph" resultType="io.metersphere.dto.RelationshipGraphData$Node">
select id,num,`name`

View File

@ -416,13 +416,13 @@
</update>
<select id="countByProjectID" resultType="java.lang.Long">
SELECT COUNT(DISTINCT ref_id) AS countNumber FROM api_scenario WHERE project_id = #{0} AND status != 'Trash'
SELECT COUNT(DISTINCT ref_id) AS countNumber FROM api_scenario WHERE project_id = #{0} AND status != 'Trash' AND latest = 1
</select>
<select id="selectIdAndScenarioByProjectId" resultType="io.metersphere.base.domain.ApiScenarioWithBLOBs">
SELECT id,scenario_definition FROM api_scenario WHERE project_id = #{0} AND status != 'Trash'
</select>
<select id="selectIdAndUseUrlByProjectId" resultType="io.metersphere.base.domain.ApiScenarioWithBLOBs">
SELECT id,use_url FROM api_scenario WHERE project_id = #{0} AND status != 'Trash'
SELECT id,use_url FROM api_scenario WHERE project_id = #{0} AND status != 'Trash' AND latest = 1
</select>
<select id="countByProjectIDAndCreatInThisWeek" resultType="java.lang.Long">
SELECT count(id) AS countNumber FROM api_scenario

View File

@ -230,7 +230,7 @@
SELECT count(ar.id) AS countNumber FROM
api_scenario_report ar
INNER JOIN (
SELECT acitem.`name`,acitem.id FROM api_scenario acitem INNER JOIN `schedule` sc ON acitem.id = sc.resource_id
SELECT acitem.`name`,acitem.id FROM api_scenario acitem INNER JOIN `schedule` sc ON acitem.id = sc.resource_id and latest = 1
) ac on ar.scenario_id = ac.id
WHERE ar.project_id = #{projectId} AND ar.trigger_mode = 'SCHEDULE' AND ar.create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
</select>
@ -239,7 +239,7 @@
SELECT count(ar.id) AS countNumber,ar.status AS groupField FROM
api_scenario_report ar
INNER JOIN (
SELECT acitem.`name`,acitem.id FROM api_scenario acitem INNER JOIN `schedule` sc ON acitem.id = sc.resource_id
SELECT acitem.`name`,acitem.id FROM api_scenario acitem INNER JOIN `schedule` sc ON acitem.id = sc.resource_id and latest = 1
) ac on ar.scenario_id = ac.id
WHERE ar.project_id = #{projectId} AND ar.trigger_mode = 'SCHEDULE'
GROUP BY groupField;

View File

@ -542,7 +542,7 @@
<select id="countProtocolByProjectID" resultType="io.metersphere.api.dto.datacount.ApiDataCountResult">
SELECT apiDef.protocol AS groupField,COUNT(testCase.id) AS countNumber FROM api_test_case testCase
INNER JOIN api_definition apiDef ON testCase.api_definition_id = apiDef.id
WHERE testCase.project_id = #{0} AND (testCase.status IS NULL or testCase.status != "Trash")
WHERE testCase.project_id = #{0} AND (testCase.status IS NULL or testCase.status != "Trash") and latest = 1
GROUP BY apiDef.protocol
</select>
<select id="findApiUrlAndMethodById" resultType="io.metersphere.base.domain.ApiDefinition">
@ -556,6 +556,7 @@
INNER JOIN api_definition apiDef ON testCase.api_definition_id = apiDef.id
WHERE testCase.project_id = #{projectId}AND apiDef.status != "Trash"
AND testCase.create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
and latest = 1
</select>
<select id="moduleCount" resultType="java.lang.Integer">

View File

@ -49,7 +49,7 @@
SELECT COUNT(id) AS countNumber
FROM `schedule`
WHERE resource_id IN (
SELECT id FROM api_scenario WHERE project_id = #{0,jdbcType=VARCHAR} AND status != 'Trash'
SELECT id FROM api_scenario WHERE project_id = #{0,jdbcType=VARCHAR} AND status != 'Trash' AND latest = 1
)
</select>
<select id="countTaskByProjectIdAndCreateTimeRange" resultType="java.lang.Long">
@ -59,9 +59,9 @@
SELECT scene.id
FROM api_scenario scene
WHERE scene.project_id = #{projectId,jdbcType=VARCHAR}
AND scene.status != 'Trash'
AND scene.status != 'Trash' AND latest = 1
)
AND create_time BETWEEN #{startTime} and #{endTime}
AND create_time BETWEEN #{startTime} AND #{endTime}
</select>
<select id="findRunningTaskInfoByProjectID" resultType="io.metersphere.api.dto.datacount.response.TaskInfoResult">
SELECT sch.id AS taskID,