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 fa85a19069
commit 0468ec5110
12 changed files with 157 additions and 66 deletions

View File

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

View File

@ -314,6 +314,76 @@ public class TestCaseIssuesExample {
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() {
addCriterion("ref_id is null");
return (Criteria) this;
@ -384,73 +454,63 @@ public class TestCaseIssuesExample {
return (Criteria) this;
}
public Criteria andRefTypeIsNull() {
addCriterion("ref_type is null");
public Criteria andRelateTimeIsNull() {
addCriterion("relate_time is null");
return (Criteria) this;
}
public Criteria andRefTypeIsNotNull() {
addCriterion("ref_type is not null");
public Criteria andRelateTimeIsNotNull() {
addCriterion("relate_time is not null");
return (Criteria) this;
}
public Criteria andRefTypeEqualTo(String value) {
addCriterion("ref_type =", value, "refType");
public Criteria andRelateTimeEqualTo(Long value) {
addCriterion("relate_time =", value, "relateTime");
return (Criteria) this;
}
public Criteria andRefTypeNotEqualTo(String value) {
addCriterion("ref_type <>", value, "refType");
public Criteria andRelateTimeNotEqualTo(Long value) {
addCriterion("relate_time <>", value, "relateTime");
return (Criteria) this;
}
public Criteria andRefTypeGreaterThan(String value) {
addCriterion("ref_type >", value, "refType");
public Criteria andRelateTimeGreaterThan(Long value) {
addCriterion("relate_time >", value, "relateTime");
return (Criteria) this;
}
public Criteria andRefTypeGreaterThanOrEqualTo(String value) {
addCriterion("ref_type >=", value, "refType");
public Criteria andRelateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("relate_time >=", value, "relateTime");
return (Criteria) this;
}
public Criteria andRefTypeLessThan(String value) {
addCriterion("ref_type <", value, "refType");
public Criteria andRelateTimeLessThan(Long value) {
addCriterion("relate_time <", value, "relateTime");
return (Criteria) this;
}
public Criteria andRefTypeLessThanOrEqualTo(String value) {
addCriterion("ref_type <=", value, "refType");
public Criteria andRelateTimeLessThanOrEqualTo(Long value) {
addCriterion("relate_time <=", value, "relateTime");
return (Criteria) this;
}
public Criteria andRefTypeLike(String value) {
addCriterion("ref_type like", value, "refType");
public Criteria andRelateTimeIn(List<Long> values) {
addCriterion("relate_time in", values, "relateTime");
return (Criteria) this;
}
public Criteria andRefTypeNotLike(String value) {
addCriterion("ref_type not like", value, "refType");
public Criteria andRelateTimeNotIn(List<Long> values) {
addCriterion("relate_time not in", values, "relateTime");
return (Criteria) this;
}
public Criteria andRefTypeIn(List<String> values) {
addCriterion("ref_type in", values, "refType");
public Criteria andRelateTimeBetween(Long value1, Long value2) {
addCriterion("relate_time between", value1, value2, "relateTime");
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");
public Criteria andRelateTimeNotBetween(Long value1, Long value2) {
addCriterion("relate_time not between", value1, value2, "relateTime");
return (Criteria) this;
}
}
@ -547,4 +607,4 @@ public class TestCaseIssuesExample {
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.TestCaseIssuesExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TestCaseIssuesMapper {
@ -29,4 +28,4 @@ public interface TestCaseIssuesMapper {
int updateByPrimaryKey(TestCaseIssues record);
}
}

View File

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

View File

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

View File

@ -91,6 +91,8 @@ public interface ExtTestCaseMapper {
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 getTestPlanPassCase(@Param("planId") String planId);

View File

@ -894,6 +894,16 @@
join issues on tci.issues_id = issues.id
where tptc.plan_id = #{planId} and tptc.is_del != 1
</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 count(s)
from (select tptc.id as s

View File

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

View File

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

View File

@ -188,7 +188,7 @@ public class TrackService {
int thisWeekCount = 0;
if (CollectionUtils.isNotEmpty(unClosedIds)) {
thisWeekCount = extIssuesMapper.getThisWeekIssueCount(unClosedIds, projectId).intValue();
thisWeekCount = extTestCaseMapper.getTestPlanThisWeekBugCount(planId, unClosedIds).intValue();
}
bugSizeMap.put("thisWeekCount", thisWeekCount);
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 class="main-info">
<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 class="addition-info">
<el-row :gutter="24" style="margin: 0">