fix(测试跟踪): 测试跟踪首页缺陷统计有误

--bug=1019998 --user=宋昌昌 【测试跟踪】首页-测试计划遗留缺陷统计-本周新增统计有误 https://www.tapd.cn/55049933/s/1300156
This commit is contained in:
song-cc-rock 2022-11-21 20:54:49 +08:00 committed by jianxing
parent c825fe023e
commit e88ef257c2
12 changed files with 157 additions and 66 deletions

View File

@ -1,8 +1,7 @@
package io.metersphere.base.domain; package io.metersphere.base.domain;
import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import lombok.Data;
@Data @Data
public class TestCaseIssues implements Serializable { public class TestCaseIssues implements Serializable {
@ -12,9 +11,11 @@ public class TestCaseIssues implements Serializable {
private String issuesId; private String issuesId;
private String refId;
private String refType; private String refType;
private String refId;
private Long relateTime;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -314,6 +314,76 @@ public class TestCaseIssuesExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRefTypeIsNull() {
addCriterion("ref_type is null");
return (Criteria) this;
}
public Criteria andRefTypeIsNotNull() {
addCriterion("ref_type is not null");
return (Criteria) this;
}
public Criteria andRefTypeEqualTo(String value) {
addCriterion("ref_type =", value, "refType");
return (Criteria) this;
}
public Criteria andRefTypeNotEqualTo(String value) {
addCriterion("ref_type <>", value, "refType");
return (Criteria) this;
}
public Criteria andRefTypeGreaterThan(String value) {
addCriterion("ref_type >", value, "refType");
return (Criteria) this;
}
public Criteria andRefTypeGreaterThanOrEqualTo(String value) {
addCriterion("ref_type >=", value, "refType");
return (Criteria) this;
}
public Criteria andRefTypeLessThan(String value) {
addCriterion("ref_type <", value, "refType");
return (Criteria) this;
}
public Criteria andRefTypeLessThanOrEqualTo(String value) {
addCriterion("ref_type <=", value, "refType");
return (Criteria) this;
}
public Criteria andRefTypeLike(String value) {
addCriterion("ref_type like", value, "refType");
return (Criteria) this;
}
public Criteria andRefTypeNotLike(String value) {
addCriterion("ref_type not like", value, "refType");
return (Criteria) this;
}
public Criteria andRefTypeIn(List<String> values) {
addCriterion("ref_type in", values, "refType");
return (Criteria) this;
}
public Criteria andRefTypeNotIn(List<String> values) {
addCriterion("ref_type not in", values, "refType");
return (Criteria) this;
}
public Criteria andRefTypeBetween(String value1, String value2) {
addCriterion("ref_type between", value1, value2, "refType");
return (Criteria) this;
}
public Criteria andRefTypeNotBetween(String value1, String value2) {
addCriterion("ref_type not between", value1, value2, "refType");
return (Criteria) this;
}
public Criteria andRefIdIsNull() { public Criteria andRefIdIsNull() {
addCriterion("ref_id is null"); addCriterion("ref_id is null");
return (Criteria) this; return (Criteria) this;
@ -384,73 +454,63 @@ public class TestCaseIssuesExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRefTypeIsNull() { public Criteria andRelateTimeIsNull() {
addCriterion("ref_type is null"); addCriterion("relate_time is null");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRefTypeIsNotNull() { public Criteria andRelateTimeIsNotNull() {
addCriterion("ref_type is not null"); addCriterion("relate_time is not null");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRefTypeEqualTo(String value) { public Criteria andRelateTimeEqualTo(Long value) {
addCriterion("ref_type =", value, "refType"); addCriterion("relate_time =", value, "relateTime");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRefTypeNotEqualTo(String value) { public Criteria andRelateTimeNotEqualTo(Long value) {
addCriterion("ref_type <>", value, "refType"); addCriterion("relate_time <>", value, "relateTime");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRefTypeGreaterThan(String value) { public Criteria andRelateTimeGreaterThan(Long value) {
addCriterion("ref_type >", value, "refType"); addCriterion("relate_time >", value, "relateTime");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRefTypeGreaterThanOrEqualTo(String value) { public Criteria andRelateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("ref_type >=", value, "refType"); addCriterion("relate_time >=", value, "relateTime");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRefTypeLessThan(String value) { public Criteria andRelateTimeLessThan(Long value) {
addCriterion("ref_type <", value, "refType"); addCriterion("relate_time <", value, "relateTime");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRefTypeLessThanOrEqualTo(String value) { public Criteria andRelateTimeLessThanOrEqualTo(Long value) {
addCriterion("ref_type <=", value, "refType"); addCriterion("relate_time <=", value, "relateTime");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRefTypeLike(String value) { public Criteria andRelateTimeIn(List<Long> values) {
addCriterion("ref_type like", value, "refType"); addCriterion("relate_time in", values, "relateTime");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRefTypeNotLike(String value) { public Criteria andRelateTimeNotIn(List<Long> values) {
addCriterion("ref_type not like", value, "refType"); addCriterion("relate_time not in", values, "relateTime");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRefTypeIn(List<String> values) { public Criteria andRelateTimeBetween(Long value1, Long value2) {
addCriterion("ref_type in", values, "refType"); addCriterion("relate_time between", value1, value2, "relateTime");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andRefTypeNotIn(List<String> values) { public Criteria andRelateTimeNotBetween(Long value1, Long value2) {
addCriterion("ref_type not in", values, "refType"); addCriterion("relate_time not between", value1, value2, "relateTime");
return (Criteria) this;
}
public Criteria andRefTypeBetween(String value1, String value2) {
addCriterion("ref_type between", value1, value2, "refType");
return (Criteria) this;
}
public Criteria andRefTypeNotBetween(String value1, String value2) {
addCriterion("ref_type not between", value1, value2, "refType");
return (Criteria) this; return (Criteria) this;
} }
} }
@ -547,4 +607,4 @@ public class TestCaseIssuesExample {
this(condition, value, secondValue, null); this(condition, value, secondValue, null);
} }
} }
} }

View File

@ -3,7 +3,6 @@ package io.metersphere.base.mapper;
import io.metersphere.base.domain.TestCaseIssues; import io.metersphere.base.domain.TestCaseIssues;
import io.metersphere.base.domain.TestCaseIssuesExample; import io.metersphere.base.domain.TestCaseIssuesExample;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
public interface TestCaseIssuesMapper { public interface TestCaseIssuesMapper {
@ -29,4 +28,4 @@ public interface TestCaseIssuesMapper {
int updateByPrimaryKey(TestCaseIssues record); int updateByPrimaryKey(TestCaseIssues record);
} }

View File

@ -5,8 +5,9 @@
<id column="id" jdbcType="VARCHAR" property="id" /> <id column="id" jdbcType="VARCHAR" property="id" />
<result column="resource_id" jdbcType="VARCHAR" property="resourceId" /> <result column="resource_id" jdbcType="VARCHAR" property="resourceId" />
<result column="issues_id" jdbcType="VARCHAR" property="issuesId" /> <result column="issues_id" jdbcType="VARCHAR" property="issuesId" />
<result column="ref_id" jdbcType="VARCHAR" property="refId" />
<result column="ref_type" jdbcType="VARCHAR" property="refType" /> <result column="ref_type" jdbcType="VARCHAR" property="refType" />
<result column="ref_id" jdbcType="VARCHAR" property="refId" />
<result column="relate_time" jdbcType="BIGINT" property="relateTime" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
@ -67,7 +68,7 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, resource_id, issues_id, ref_id, ref_type id, resource_id, issues_id, ref_type, ref_id, relate_time
</sql> </sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.TestCaseIssuesExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="io.metersphere.base.domain.TestCaseIssuesExample" resultMap="BaseResultMap">
select select
@ -101,9 +102,11 @@
</delete> </delete>
<insert id="insert" parameterType="io.metersphere.base.domain.TestCaseIssues"> <insert id="insert" parameterType="io.metersphere.base.domain.TestCaseIssues">
insert into test_case_issues (id, resource_id, issues_id, insert into test_case_issues (id, resource_id, issues_id,
ref_id, ref_type) ref_type, ref_id, relate_time
)
values (#{id,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR}, #{issuesId,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR}, #{issuesId,jdbcType=VARCHAR},
#{refId,jdbcType=VARCHAR}, #{refType,jdbcType=VARCHAR}) #{refType,jdbcType=VARCHAR}, #{refId,jdbcType=VARCHAR}, #{relateTime,jdbcType=BIGINT}
)
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestCaseIssues"> <insert id="insertSelective" parameterType="io.metersphere.base.domain.TestCaseIssues">
insert into test_case_issues insert into test_case_issues
@ -117,11 +120,14 @@
<if test="issuesId != null"> <if test="issuesId != null">
issues_id, issues_id,
</if> </if>
<if test="refType != null">
ref_type,
</if>
<if test="refId != null"> <if test="refId != null">
ref_id, ref_id,
</if> </if>
<if test="refType != null"> <if test="relateTime != null">
ref_type, relate_time,
</if> </if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
@ -134,11 +140,14 @@
<if test="issuesId != null"> <if test="issuesId != null">
#{issuesId,jdbcType=VARCHAR}, #{issuesId,jdbcType=VARCHAR},
</if> </if>
<if test="refType != null">
#{refType,jdbcType=VARCHAR},
</if>
<if test="refId != null"> <if test="refId != null">
#{refId,jdbcType=VARCHAR}, #{refId,jdbcType=VARCHAR},
</if> </if>
<if test="refType != null"> <if test="relateTime != null">
#{refType,jdbcType=VARCHAR}, #{relateTime,jdbcType=BIGINT},
</if> </if>
</trim> </trim>
</insert> </insert>
@ -160,11 +169,14 @@
<if test="record.issuesId != null"> <if test="record.issuesId != null">
issues_id = #{record.issuesId,jdbcType=VARCHAR}, issues_id = #{record.issuesId,jdbcType=VARCHAR},
</if> </if>
<if test="record.refType != null">
ref_type = #{record.refType,jdbcType=VARCHAR},
</if>
<if test="record.refId != null"> <if test="record.refId != null">
ref_id = #{record.refId,jdbcType=VARCHAR}, ref_id = #{record.refId,jdbcType=VARCHAR},
</if> </if>
<if test="record.refType != null"> <if test="record.relateTime != null">
ref_type = #{record.refType,jdbcType=VARCHAR}, relate_time = #{record.relateTime,jdbcType=BIGINT},
</if> </if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
@ -174,10 +186,11 @@
<update id="updateByExample" parameterType="map"> <update id="updateByExample" parameterType="map">
update test_case_issues update test_case_issues
set id = #{record.id,jdbcType=VARCHAR}, set id = #{record.id,jdbcType=VARCHAR},
resource_id = #{record.resourceId,jdbcType=VARCHAR}, resource_id = #{record.resourceId,jdbcType=VARCHAR},
issues_id = #{record.issuesId,jdbcType=VARCHAR}, issues_id = #{record.issuesId,jdbcType=VARCHAR},
ref_id = #{record.refId,jdbcType=VARCHAR}, ref_type = #{record.refType,jdbcType=VARCHAR},
ref_type = #{record.refType,jdbcType=VARCHAR} ref_id = #{record.refId,jdbcType=VARCHAR},
relate_time = #{record.relateTime,jdbcType=BIGINT}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -191,11 +204,14 @@
<if test="issuesId != null"> <if test="issuesId != null">
issues_id = #{issuesId,jdbcType=VARCHAR}, issues_id = #{issuesId,jdbcType=VARCHAR},
</if> </if>
<if test="refType != null">
ref_type = #{refType,jdbcType=VARCHAR},
</if>
<if test="refId != null"> <if test="refId != null">
ref_id = #{refId,jdbcType=VARCHAR}, ref_id = #{refId,jdbcType=VARCHAR},
</if> </if>
<if test="refType != null"> <if test="relateTime != null">
ref_type = #{refType,jdbcType=VARCHAR}, relate_time = #{relateTime,jdbcType=BIGINT},
</if> </if>
</set> </set>
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
@ -203,9 +219,10 @@
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.TestCaseIssues"> <update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.TestCaseIssues">
update test_case_issues update test_case_issues
set resource_id = #{resourceId,jdbcType=VARCHAR}, set resource_id = #{resourceId,jdbcType=VARCHAR},
issues_id = #{issuesId,jdbcType=VARCHAR}, issues_id = #{issuesId,jdbcType=VARCHAR},
ref_id = #{refId,jdbcType=VARCHAR}, ref_type = #{refType,jdbcType=VARCHAR},
ref_type = #{refType,jdbcType=VARCHAR} ref_id = #{refId,jdbcType=VARCHAR},
relate_time = #{relateTime,jdbcType=BIGINT}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>

View File

@ -174,8 +174,7 @@
from test_plan_test_case tptc from test_plan_test_case tptc
join test_plan tp on tp.id = tptc.plan_id join test_plan tp on tp.id = tptc.plan_id
join test_case_issues tci on tptc.id = tci.resource_id join test_case_issues tci on tptc.id = tci.resource_id
join issues on tci.issues_id = issues.id where tptc.is_del != 1 and date_sub(curdate(), interval 7 day) &lt;= from_unixtime(round(tci.relate_time / 1000, 0))
where tptc.is_del != 1 and date_sub(curdate(), interval 7 day) &lt;= from_unixtime(round(issues.create_time / 1000, 0))
and tp.project_id = #{projectId} and tp.project_id = #{projectId}
</select> </select>

View File

@ -91,6 +91,8 @@ public interface ExtTestCaseMapper {
List<String> getTestPlanBug(@Param("planId") String planId); List<String> getTestPlanBug(@Param("planId") String planId);
Long getTestPlanThisWeekBugCount(@Param("planId") String planId, @Param("ids") List<String> ids);
int getTestPlanCase(@Param("planId") String planId); int getTestPlanCase(@Param("planId") String planId);
int getTestPlanPassCase(@Param("planId") String planId); int getTestPlanPassCase(@Param("planId") String planId);

View File

@ -894,6 +894,16 @@
join issues on tci.issues_id = issues.id join issues on tci.issues_id = issues.id
where tptc.plan_id = #{planId} and tptc.is_del != 1 where tptc.plan_id = #{planId} and tptc.is_del != 1
</select> </select>
<select id="getTestPlanThisWeekBugCount" resultType="java.lang.Long">
select count(distinct tci.issues_id)
from test_plan_test_case tptc
join test_case_issues tci on tptc.id = tci.resource_id
where tptc.plan_id = #{planId} and tptc.is_del != 1 and date_sub(curdate(), interval 7 day) &lt;= from_unixtime(round(tci.relate_time / 1000, 0))
and tci.issues_id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</select>
<select id="getTestPlanCase" resultType="int"> <select id="getTestPlanCase" resultType="int">
select count(s) select count(s)
from (select tptc.id as s from (select tptc.id as s

View File

@ -122,6 +122,7 @@ public class TestCaseIssueService {
testCaseIssues.setResourceId(resourceId); testCaseIssues.setResourceId(resourceId);
testCaseIssues.setRefType(refType); testCaseIssues.setRefType(refType);
testCaseIssues.setRefId(StringUtils.isNotBlank(refId) ? null : refId); testCaseIssues.setRefId(StringUtils.isNotBlank(refId) ? null : refId);
testCaseIssues.setRelateTime(System.currentTimeMillis());
testCaseIssuesMapper.insert(testCaseIssues); testCaseIssuesMapper.insert(testCaseIssues);
} }
} }

View File

@ -487,6 +487,7 @@ public class TestCaseService {
t.setId(UUID.randomUUID().toString()); t.setId(UUID.randomUUID().toString());
t.setResourceId(testCase.getId()); t.setResourceId(testCase.getId());
t.setIssuesId(issue.getId()); t.setIssuesId(issue.getId());
t.setRelateTime(System.currentTimeMillis());
testCaseIssuesMapper.insertSelective(t); testCaseIssuesMapper.insertSelective(t);
}); });
} }

View File

@ -188,7 +188,7 @@ public class TrackService {
int thisWeekCount = 0; int thisWeekCount = 0;
if (CollectionUtils.isNotEmpty(unClosedIds)) { if (CollectionUtils.isNotEmpty(unClosedIds)) {
thisWeekCount = extIssuesMapper.getThisWeekIssueCount(unClosedIds, projectId).intValue(); thisWeekCount = extTestCaseMapper.getTestPlanThisWeekBugCount(planId, unClosedIds).intValue();
} }
bugSizeMap.put("thisWeekCount", thisWeekCount); bugSizeMap.put("thisWeekCount", thisWeekCount);
return bugSizeMap; return bugSizeMap;

View File

@ -0,0 +1 @@
ALTER TABLE test_case_issues ADD relate_time BIGINT(13) NULL COMMENT 'relate time';

View File

@ -15,7 +15,7 @@
<div v-show="!loadError"> <div v-show="!loadError">
<div class="main-info"> <div class="main-info">
<count-chart :chart-data="bugData.chartData" :main-title="chartMainTitle" <count-chart :chart-data="bugData.chartData" :main-title="chartMainTitle"
:week-count="bugData.thisWeekAddedCount" :chart-sub-link="chartRedirectLink" ref="countChart" @redirectPage="redirectPage"/> :week-count="bugData.thisWeekCount" :chart-sub-link="chartRedirectLink" ref="countChart" @redirectPage="redirectPage"/>
</div> </div>
<div class="addition-info"> <div class="addition-info">
<el-row :gutter="24" style="margin: 0"> <el-row :gutter="24" style="margin: 0">