fix(报告统计): 测试用例趋势报表查看项目不再以工作空间为条件

--bug=1018948 --user=宋天阳 【报表统计】用户A在测试用例趋势的项目列表中可以看见所有项目
https://www.tapd.cn/55049933/s/1283953
This commit is contained in:
song-tianyang 2022-10-31 17:12:19 +08:00 committed by 建国
parent ad228271e3
commit 189eb23bea
6 changed files with 22 additions and 44 deletions

View File

@ -2,14 +2,12 @@ package io.metersphere.reportstatistics.service;
import io.metersphere.commons.utils.DateUtils;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.ProjectDTO;
import io.metersphere.reportstatistics.dto.*;
import io.metersphere.reportstatistics.dto.charts.Legend;
import io.metersphere.reportstatistics.dto.charts.Series;
import io.metersphere.reportstatistics.dto.charts.XAxis;
import io.metersphere.reportstatistics.dto.charts.YAxis;
import io.metersphere.reportstatistics.service.remote.track.TestCaseRemoteService;
import io.metersphere.request.ProjectRequest;
import io.metersphere.service.BaseProjectService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -39,17 +37,10 @@ public class TestAnalysisService {
request.setStartTime(DateUtils.getDataStr(request.getTimes().get(0)));
request.setEndTime(DateUtils.getDataStr(request.getTimes().get(1)));
if (CollectionUtils.isEmpty(request.getProjects())) {
// 获取当前组织空间下所有项目
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId();
ProjectRequest projectRequest = new ProjectRequest();
projectRequest.setWorkspaceId(currentWorkspaceId);
List<ProjectDTO> projectDTOS = projectService.getProjectList(projectRequest);
if (CollectionUtils.isNotEmpty(projectDTOS)) {
request.setProjects(projectDTOS.stream().map(ProjectDTO::getId).collect(Collectors.toList()));
} else {
request.setProjects(new LinkedList<String>() {{
this.add(UUID.randomUUID().toString());
String projectId = SessionUtils.getCurrentProjectId();
if (StringUtils.isNotBlank(projectId)) {
request.setProjects(new ArrayList<>() {{
this.add(projectId);
}});
}
}
@ -117,7 +108,10 @@ public class TestAnalysisService {
List<Integer> upCollect = dtos.stream().map(item -> Integer.valueOf(item.getUpdateCount())).collect(Collectors.toList());
// reduce求和
Optional<Integer> updateCount = upCollect.stream().reduce(Integer::sum);
dtos.add(new TestAnalysisTableDTO("Count", createCount.get().toString(), updateCount.get().toString(), new LinkedList<>()));
dtos.add(new TestAnalysisTableDTO("Count",
createCount.isEmpty() ? "0" : createCount.get().toString(),
updateCount.isEmpty() ? "0" : updateCount.get().toString(),
new LinkedList<>()));
TestAnalysisResult testAnalysisResult = new TestAnalysisResult();
testAnalysisResult.setChartDTO(dto);

View File

@ -1,9 +1,5 @@
import {get} from "metersphere-frontend/src/plugins/request"
export function listAllProject(workspaceId) {
return get(`/project/listAll/${workspaceId}`)
}
export function getProject(id) {
return get(`/project/get/${id}`)
}

View File

@ -30,8 +30,8 @@
</el-row>
<el-row style="overflow: auto">
<ms-chart ref="chart1" v-if="!loading" :options="dataOption"
:style="{width: chartWidthNumber+'px', height: (h-70) + 'px'}" class="chart-config" :autoresize="true"
:id="reportId"/>
:style="{width: '100%', height: (h-70) + 'px'}" class="chart-config" :autoresize="true"
id="picChart"/>
</el-row>
</el-card>
</div>

View File

@ -1,13 +1,12 @@
<template>
<div>
<el-container v-loading="loading" id="reportAnalysis" :style="{ 'max-height': (h-50) + 'px', 'overflow': 'auto'}">
<el-container v-loading="loading" :style="{ 'max-height': (h-50) + 'px', 'overflow': 'auto'}">
<el-aside v-if="!isHide" :width="!isHide ?'235px':'0px'" :style="{ 'margin-left': '5px'}">
<history-report-data report-type="TEST_CASE_COUNT"
@selectReport="selectReport" @removeHistoryReportId="removeHistoryReportId"
ref="historyReport"/>
</el-aside>
<el-main class="ms-main" style="padding: 0px 5px 0px">
<el-main class="ms-main" id="reportAnalysis" style="padding: 0px 5px 0px">
<div>
<test-case-count-chart @hidePage="hidePage" @orderCharts="orderCharts"
ref="analysisChart" @updateChartType="updateChartType"

View File

@ -1,13 +1,13 @@
<template>
<div :style="{ height: h + 'px'}">
<el-container v-loading="loading" id="reportAnalysis" style="overflow: scroll">
<el-container v-loading="loading" style="overflow: scroll">
<el-container class="ms-row">
<el-aside :width="!isHide ?'235px':'0px'" style="margin-left: 5px; max-height: 843px">
<history-report-data report-type="TEST_CASE_ANALYSIS"
@selectReport="selectReport" @removeHistoryReportId="removeHistoryReportId"
ref="historyReport"/>
</el-aside>
<el-main class="ms-main">
<el-main class="ms-main" id="reportAnalysis">
<div>
<test-analysis-chart @hidePage="hidePage" @orderCharts="orderCharts" ref="analysisChart"
:load-option="loadOption"/>

View File

@ -54,8 +54,8 @@
<script>
import MsSelectTree from "@/business/compnent/form/MsSelectTree";
import {listAllProject} from "@/api/project";
import {getCurrentWorkspaceId} from "metersphere-frontend/src/utils/token";
import {getProject} from "@/api/project";
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
import {selectTestCaseNodeList, selectUserProjectMember} from "@/api/resource";
export default {
@ -147,15 +147,13 @@ export default {
}
},
init: function () {
let workspaceId = getCurrentWorkspaceId();
this.loading = listAllProject(workspaceId).then(response => {
let projects = response.data;
if (projects) {
let projectId = getCurrentProjectID();
this.loading = getProject(projectId).then(response => {
let project = response.data;
if (project) {
this.items = [];
projects.forEach(item => {
let data = {id: item.id, label: item.name};
this.items.push(data);
})
let data = {id: project.id, label: project.name};
this.items.push(data);
}
}).catch(() => {
this.loading = false;
@ -178,9 +176,6 @@ export default {
});
},
setProjects(key, data, data2) {//
let selectNodeIds = this.$refs.projectSelector.selectNodeIds;
if (!key || key === "") {
key = [];
}
@ -192,19 +187,13 @@ export default {
} else {
this.disabled = false;
}
if (this.syncReport) {
this.$emit('filterCharts', this.option);
}
this.$nextTick(() => {
console.info("------>");
console.info(this.option.projects);
console.info("<------");
if (this.option.projects && this.option.projects.length == 1) {
this.initModule();
}
})
},