fix:测试用例和测试计划选择100条/页显示,页面非常卡顿

This commit is contained in:
wenyann 2021-06-25 11:28:05 +08:00 committed by 刘瑞斌
parent 056246c112
commit 9c63bdceab
12 changed files with 217 additions and 80 deletions

View File

@ -1,9 +1,9 @@
package io.metersphere.base.domain;
import lombok.Data;
import java.io.Serializable;
import lombok.Data;
@Data
public class TestPlanTestCase implements Serializable {
private String id;
@ -26,5 +26,7 @@ public class TestPlanTestCase implements Serializable {
private String createUser;
private Integer issuesCount;
private static final long serialVersionUID = 1L;
}

View File

@ -783,6 +783,66 @@ public class TestPlanTestCaseExample {
addCriterion("create_user not between", value1, value2, "createUser");
return (Criteria) this;
}
public Criteria andIssuesCountIsNull() {
addCriterion("issues_count is null");
return (Criteria) this;
}
public Criteria andIssuesCountIsNotNull() {
addCriterion("issues_count is not null");
return (Criteria) this;
}
public Criteria andIssuesCountEqualTo(Integer value) {
addCriterion("issues_count =", value, "issuesCount");
return (Criteria) this;
}
public Criteria andIssuesCountNotEqualTo(Integer value) {
addCriterion("issues_count <>", value, "issuesCount");
return (Criteria) this;
}
public Criteria andIssuesCountGreaterThan(Integer value) {
addCriterion("issues_count >", value, "issuesCount");
return (Criteria) this;
}
public Criteria andIssuesCountGreaterThanOrEqualTo(Integer value) {
addCriterion("issues_count >=", value, "issuesCount");
return (Criteria) this;
}
public Criteria andIssuesCountLessThan(Integer value) {
addCriterion("issues_count <", value, "issuesCount");
return (Criteria) this;
}
public Criteria andIssuesCountLessThanOrEqualTo(Integer value) {
addCriterion("issues_count <=", value, "issuesCount");
return (Criteria) this;
}
public Criteria andIssuesCountIn(List<Integer> values) {
addCriterion("issues_count in", values, "issuesCount");
return (Criteria) this;
}
public Criteria andIssuesCountNotIn(List<Integer> values) {
addCriterion("issues_count not in", values, "issuesCount");
return (Criteria) this;
}
public Criteria andIssuesCountBetween(Integer value1, Integer value2) {
addCriterion("issues_count between", value1, value2, "issuesCount");
return (Criteria) this;
}
public Criteria andIssuesCountNotBetween(Integer value1, Integer value2) {
addCriterion("issues_count not between", value1, value2, "issuesCount");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -12,6 +12,7 @@
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="report_id" jdbcType="VARCHAR" property="reportId" />
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
<result column="issues_count" jdbcType="INTEGER" property="issuesCount"/>
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.TestPlanTestCaseWithBLOBs">
<result column="results" jdbcType="LONGVARCHAR" property="results" />
@ -78,7 +79,7 @@
</sql>
<sql id="Base_Column_List">
id, plan_id, case_id, executor, `status`, remark, create_time, update_time, report_id,
create_user
create_user, issues_count
</sql>
<sql id="Blob_Column_List">
results, issues, actual_result
@ -132,16 +133,16 @@
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.TestPlanTestCaseWithBLOBs">
insert into test_plan_test_case (id, plan_id, case_id,
executor, `status`, remark,
create_time, update_time, report_id,
create_user, results, issues,
actual_result)
values (#{id,jdbcType=VARCHAR}, #{planId,jdbcType=VARCHAR}, #{caseId,jdbcType=VARCHAR},
#{executor,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{reportId,jdbcType=VARCHAR},
#{createUser,jdbcType=VARCHAR}, #{results,jdbcType=LONGVARCHAR}, #{issues,jdbcType=LONGVARCHAR},
#{actualResult,jdbcType=LONGVARCHAR})
insert into test_plan_test_case (id, plan_id, case_id,
executor, `status`, remark,
create_time, update_time, report_id,
create_user, issues_count, results,
issues, actual_result)
values (#{id,jdbcType=VARCHAR}, #{planId,jdbcType=VARCHAR}, #{caseId,jdbcType=VARCHAR},
#{executor,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{reportId,jdbcType=VARCHAR},
#{createUser,jdbcType=VARCHAR}, #{issuesCount,jdbcType=INTEGER}, #{results,jdbcType=LONGVARCHAR},
#{issues,jdbcType=LONGVARCHAR}, #{actualResult,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlanTestCaseWithBLOBs">
insert into test_plan_test_case
@ -176,6 +177,9 @@
<if test="createUser != null">
create_user,
</if>
<if test="issuesCount != null">
issues_count,
</if>
<if test="results != null">
results,
</if>
@ -217,6 +221,9 @@
<if test="createUser != null">
#{createUser,jdbcType=VARCHAR},
</if>
<if test="issuesCount != null">
#{issuesCount,jdbcType=INTEGER},
</if>
<if test="results != null">
#{results,jdbcType=LONGVARCHAR},
</if>
@ -267,6 +274,9 @@
<if test="record.createUser != null">
create_user = #{record.createUser,jdbcType=VARCHAR},
</if>
<if test="record.issuesCount != null">
issues_count = #{record.issuesCount,jdbcType=INTEGER},
</if>
<if test="record.results != null">
results = #{record.results,jdbcType=LONGVARCHAR},
</if>
@ -284,18 +294,19 @@
<update id="updateByExampleWithBLOBs" parameterType="map">
update test_plan_test_case
set id = #{record.id,jdbcType=VARCHAR},
plan_id = #{record.planId,jdbcType=VARCHAR},
case_id = #{record.caseId,jdbcType=VARCHAR},
executor = #{record.executor,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
remark = #{record.remark,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
report_id = #{record.reportId,jdbcType=VARCHAR},
create_user = #{record.createUser,jdbcType=VARCHAR},
results = #{record.results,jdbcType=LONGVARCHAR},
issues = #{record.issues,jdbcType=LONGVARCHAR},
actual_result = #{record.actualResult,jdbcType=LONGVARCHAR}
plan_id = #{record.planId,jdbcType=VARCHAR},
case_id = #{record.caseId,jdbcType=VARCHAR},
executor = #{record.executor,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
remark = #{record.remark,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
report_id = #{record.reportId,jdbcType=VARCHAR},
create_user = #{record.createUser,jdbcType=VARCHAR},
issues_count = #{record.issuesCount,jdbcType=INTEGER},
results = #{record.results,jdbcType=LONGVARCHAR},
issues = #{record.issues,jdbcType=LONGVARCHAR},
actual_result = #{record.actualResult,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -303,15 +314,16 @@
<update id="updateByExample" parameterType="map">
update test_plan_test_case
set id = #{record.id,jdbcType=VARCHAR},
plan_id = #{record.planId,jdbcType=VARCHAR},
case_id = #{record.caseId,jdbcType=VARCHAR},
executor = #{record.executor,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
remark = #{record.remark,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
report_id = #{record.reportId,jdbcType=VARCHAR},
create_user = #{record.createUser,jdbcType=VARCHAR}
plan_id = #{record.planId,jdbcType=VARCHAR},
case_id = #{record.caseId,jdbcType=VARCHAR},
executor = #{record.executor,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
remark = #{record.remark,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
report_id = #{record.reportId,jdbcType=VARCHAR},
create_user = #{record.createUser,jdbcType=VARCHAR},
issues_count = #{record.issuesCount,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -346,6 +358,9 @@
<if test="createUser != null">
create_user = #{createUser,jdbcType=VARCHAR},
</if>
<if test="issuesCount != null">
issues_count = #{issuesCount,jdbcType=INTEGER},
</if>
<if test="results != null">
results = #{results,jdbcType=LONGVARCHAR},
</if>
@ -360,31 +375,33 @@
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.TestPlanTestCaseWithBLOBs">
update test_plan_test_case
set plan_id = #{planId,jdbcType=VARCHAR},
case_id = #{caseId,jdbcType=VARCHAR},
executor = #{executor,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
report_id = #{reportId,jdbcType=VARCHAR},
create_user = #{createUser,jdbcType=VARCHAR},
results = #{results,jdbcType=LONGVARCHAR},
issues = #{issues,jdbcType=LONGVARCHAR},
actual_result = #{actualResult,jdbcType=LONGVARCHAR}
set plan_id = #{planId,jdbcType=VARCHAR},
case_id = #{caseId,jdbcType=VARCHAR},
executor = #{executor,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
report_id = #{reportId,jdbcType=VARCHAR},
create_user = #{createUser,jdbcType=VARCHAR},
issues_count = #{issuesCount,jdbcType=INTEGER},
results = #{results,jdbcType=LONGVARCHAR},
issues = #{issues,jdbcType=LONGVARCHAR},
actual_result = #{actualResult,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.TestPlanTestCase">
update test_plan_test_case
set plan_id = #{planId,jdbcType=VARCHAR},
case_id = #{caseId,jdbcType=VARCHAR},
executor = #{executor,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
report_id = #{reportId,jdbcType=VARCHAR},
create_user = #{createUser,jdbcType=VARCHAR}
set plan_id = #{planId,jdbcType=VARCHAR},
case_id = #{caseId,jdbcType=VARCHAR},
executor = #{executor,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
report_id = #{reportId,jdbcType=VARCHAR},
create_user = #{createUser,jdbcType=VARCHAR},
issues_count = #{issuesCount,jdbcType=INTEGER}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -11,7 +11,6 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ExtTestPlanTestCaseMapper {
List<TestCaseReportStatusResultDTO> getReportMetric(@Param("planId") String planId);
List<String> getExecutors(@Param("planId") String planId);
@ -56,4 +55,6 @@ public interface ExtTestPlanTestCaseMapper {
List<String> selectIds(@Param("request") TestPlanFuncCaseConditions conditions);
List<String> selectIdsByQuery(@Param("request") BaseQueryRequest query);
void update(@Param("count") int count, @Param("id") String id, @Param("caseId") String caseId, @Param("issues") String issues);
}

View File

@ -230,7 +230,7 @@
test_case.custom_num) as customNum, test_plan_test_case.executor, test_plan_test_case.status,
test_plan_test_case.actual_result,
test_plan_test_case.update_time, test_plan_test_case.create_time,test_case_node.name as model, project.name as
projectName,
projectName,test_plan_test_case.issues as issues,test_plan_test_case.issues_count as issuesCount,
test_plan_test_case.plan_id as planId
from test_plan_test_case
inner join test_case on test_plan_test_case.case_id = test_case.id
@ -475,6 +475,15 @@
#{id}
</foreach>
</update>
<update id="update">
update test_plan_test_case
<set>
issues_count=#{count},
issues = #{issues}
</set>
where plan_id=#{id,jdbcType=VARCHAR} and case_id=#{caseId,jdbcType=VARCHAR}
</update>
<delete id="deleteByTestCaseID" parameterType="java.lang.String">
delete

View File

@ -0,0 +1,39 @@
package io.metersphere.job.sechedule;
import com.fit2cloud.quartz.anno.QuartzScheduled;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.IssuesDao;
import io.metersphere.base.domain.TestPlanTestCase;
import io.metersphere.base.domain.TestPlanTestCaseWithBLOBs;
import io.metersphere.track.service.IssuesService;
import io.metersphere.track.service.TestPlanTestCaseService;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
@Component
public class IssuesJob {
@Resource
private IssuesService issuesService;
@Resource
private TestPlanTestCaseService testPlanTestCaseService;
@QuartzScheduled(fixedDelay = 3600 * 1000)
//@Scheduled(fixedDelay = 3600 * 1000)
public void IssuesCount() {
int pageSize = 20;
int pages = 1;
for (int i = 0; i < pages; i++) {
Page<List<TestPlanTestCase>> page = PageHelper.startPage(i, pageSize, true);
pages = page.getPages();
List<TestPlanTestCaseWithBLOBs> list = testPlanTestCaseService.listAll();
list.forEach(l -> {
List<IssuesDao> issues = issuesService.getIssues(l.getCaseId());
int issuesCount = issues.size();
testPlanTestCaseService.updateIssues(issuesCount, l.getPlanId(), l.getCaseId(), issues.toString());
});
}
}
}

View File

@ -22,6 +22,7 @@ public class TestPlanCaseDTO extends TestCaseWithBLOBs {
private String projectName;
private String actualResult;
private String maintainerName;
private int issuesCount;
private List<TestCaseTestDTO> list;
}

View File

@ -181,8 +181,9 @@ public class IssuesService {
}
public List<String> getPlatforms(Project project) {
SessionUser user = SessionUtils.getUser();
String orgId = user.getLastOrganizationId();
String workspaceId = project.getWorkspaceId();
Workspace workspace = workspaceMapper.selectByPrimaryKey(workspaceId);
String orgId = workspace.getOrganizationId();
boolean tapd = isIntegratedPlatform(orgId, IssuesManagePlatform.Tapd.toString());
boolean jira = isIntegratedPlatform(orgId, IssuesManagePlatform.Jira.toString());
boolean zentao = isIntegratedPlatform(orgId, IssuesManagePlatform.Zentao.toString());

View File

@ -66,6 +66,16 @@ public class TestPlanTestCaseService {
@Resource
private TestCaseCommentService testCaseCommentService;
public List<TestPlanTestCaseWithBLOBs> listAll() {
TestPlanTestCaseExample example = new TestPlanTestCaseExample();
example.createCriteria();
return testPlanTestCaseMapper.selectByExampleWithBLOBs(example);
}
public void updateIssues(int issuesCount, String id, String caseId, String issues) {
extTestPlanTestCaseMapper.update(issuesCount, id, caseId, issues);
}
public List<TestPlanCaseDTO> list(QueryTestPlanCaseRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
List<TestPlanCaseDTO> list = extTestPlanTestCaseMapper.list(request);
@ -216,6 +226,7 @@ public class TestPlanTestCaseService {
/**
* 更新测试计划关联接口测试的功能用例的状态
*
* @param testId 接口测试id
*/
public void updateTestCaseStates(String testId, String testName, String planId, String testType) {
@ -318,7 +329,7 @@ public class TestPlanTestCaseService {
if (planTestCaseWithBLOBs != null) {
TestCase testCase = testCaseMapper.selectByPrimaryKey(planTestCaseWithBLOBs.getCaseId());
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planTestCaseWithBLOBs.getPlanId());
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), testCase.getProjectId(), testCase.getName(), planTestCaseWithBLOBs.getCreateUser(), new LinkedList<>());
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), testCase.getProjectId(), testCase.getName(), planTestCaseWithBLOBs.getCreateUser(), new LinkedList<>());
return JSON.toJSONString(details);
}
return null;

View File

@ -1,9 +1,17 @@
-- 添加版本号
ALTER TABLE api_scenario ADD version INT(10) DEFAULT 0 NULL COMMENT '版本号';
ALTER TABLE api_scenario
ADD version INT(10) DEFAULT 0 NULL COMMENT '版本号';
ALTER TABLE load_test ADD scenario_version INT(10) DEFAULT 0 NULL COMMENT '关联的接口自动化版本号';
ALTER TABLE load_test
ADD scenario_version INT(10) DEFAULT 0 NULL COMMENT '关联的接口自动化版本号';
ALTER TABLE load_test ADD scenario_id varchar(255) NULL COMMENT '关联的场景自动化ID';
ALTER TABLE load_test
ADD scenario_id varchar(255) NULL COMMENT '关联的场景自动化ID';
-- 测试计划用例列表添加缺陷数
alter table test_plan_test_case
add issues_count int(10) DEFAULT 0 null;
-- 对接Jira等平台认证信息
ALTER TABLE `user` ADD platform_info LONGTEXT NULL COMMENT ' 其他平台对接信息';
ALTER TABLE `user`
ADD platform_info LONGTEXT NULL COMMENT ' 其他平台对接信息';

View File

@ -64,8 +64,8 @@
<!--要生成的数据库表 -->
<!--<table tableName="auth_source"/>
<table tableName="swagger_url_project"/>
<table tableName="test_plan_test_case"/>
<!--<table tableName="swagger_url_project"/>
<table tableName="user_header"/>-->
<!--<table tableName="test_plan_api_scenario"/>-->
<!--<table tableName="test_plan"/>-->

View File

@ -464,20 +464,8 @@ export default {
this.tableData[i].customFields = JSON.parse(this.tableData[i].customFields);
}
this.$set(this.tableData[i], "showTags", JSON.parse(this.tableData[i].tags));
this.$set(this.tableData[i], "issuesSize", 0);
this.$get("/issues/get/" + this.tableData[i].caseId).then(response => {
let issues = response.data.data;
if (this.tableData[i]) {
this.$set(this.tableData[i], "issuesSize", issues.length);
this.$set(this.tableData[i], "issuesContent", issues);
}
}).catch(() => {
this.$set(this.tableData[i], "issuesContent", [{
title: '获取缺陷失败',
description: '获取缺陷失败',
platform: '获取缺陷失败'
}]);
});
this.$set(this.tableData[i], "issuesSize", this.tableData[i].issuesCount);
this.$set(this.tableData[i], "issuesContent", JSON.parse(this.tableData[i].issues));
}
}
this.$refs.table.clear();