fix(工作台): 用户被移除项目组之后工作台面板不再统计其相关数据
--bug=1027173 --user=宋天阳 【我的工作台】我的仪表盘首页 -我创建的用例-功能用例数量无统计数据 https://www.tapd.cn/55049933/s/1383870;--bug=1027174 --user=宋天阳 【我的工作台】我的关注 tab 页面没有任何统计数据 https://www.tapd.cn/55049933/s/1383869
This commit is contained in:
parent
50e1c1a14d
commit
529a9a732d
|
@ -88,7 +88,10 @@
|
||||||
select count(1) as `count`, if(i.platform = 'Local', cfi.value, i.platform_status) as statusValue, i.platform
|
select count(1) as `count`, if(i.platform = 'Local', cfi.value, i.platform_status) as statusValue, i.platform
|
||||||
from issues i
|
from issues i
|
||||||
inner join project p
|
inner join project p
|
||||||
on i.project_id = p.id and p.workspace_id = #{request.workspaceId}
|
on i.project_id = p.id and p.workspace_id = #{request.workspaceId} and
|
||||||
|
p.id IN (SELECT source_id
|
||||||
|
FROM user_group
|
||||||
|
WHERE user_id = #{request.creator})
|
||||||
left join custom_field_issues cfi
|
left join custom_field_issues cfi
|
||||||
on i.id = cfi.resource_id and field_id in (select cf.id
|
on i.id = cfi.resource_id and field_id in (select cf.id
|
||||||
from custom_field cf
|
from custom_field cf
|
||||||
|
|
|
@ -243,6 +243,12 @@
|
||||||
AND create_time >= #{request.scheduleCreateTime}
|
AND create_time >= #{request.scheduleCreateTime}
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
|
<if test="request.projectIdList != null and request.projectIdList.size() > 0">
|
||||||
|
AND project.id in
|
||||||
|
<foreach collection="request.projectIdList" item="itemId" separator="," open="(" close=")">
|
||||||
|
#{itemId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
<if test="request.ids != null and request.ids.size() > 0">
|
<if test="request.ids != null and request.ids.size() > 0">
|
||||||
AND api_scenario.id in
|
AND api_scenario.id in
|
||||||
<foreach collection="request.ids" item="itemId" separator="," open="(" close=")">
|
<foreach collection="request.ids" item="itemId" separator="," open="(" close=")">
|
||||||
|
|
|
@ -277,7 +277,6 @@
|
||||||
inner join project on api_test_case.project_id = project.id
|
inner join project on api_test_case.project_id = project.id
|
||||||
inner JOIN api_definition a ON api_test_case.api_definition_id = a.id
|
inner JOIN api_definition a ON api_test_case.api_definition_id = a.id
|
||||||
<include refid="criCondition"/>
|
<include refid="criCondition"/>
|
||||||
and a.latest = 1
|
|
||||||
</select>
|
</select>
|
||||||
<select id="getCountFollow" resultType="java.lang.Integer">
|
<select id="getCountFollow" resultType="java.lang.Integer">
|
||||||
select count(*) from api_test_case ac where
|
select count(*) from api_test_case ac where
|
||||||
|
@ -404,6 +403,12 @@
|
||||||
<if test="request.createTime >0 ">
|
<if test="request.createTime >0 ">
|
||||||
AND api_test_case.create_time >= #{request.createTime}
|
AND api_test_case.create_time >= #{request.createTime}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="request.projectIdList != null and request.projectIdList.size() > 0">
|
||||||
|
AND project.id in
|
||||||
|
<foreach collection="request.projectIdList" item="itemId" separator="," open="(" close=")">
|
||||||
|
#{itemId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,12 @@
|
||||||
<property name="objectKey" value="request.combine.tags"/>
|
<property name="objectKey" value="request.combine.tags"/>
|
||||||
</include>
|
</include>
|
||||||
</if>
|
</if>
|
||||||
|
<if test="request.projectIdList != null and request.projectIdList.size() > 0">
|
||||||
|
AND project.id in
|
||||||
|
<foreach collection="request.projectIdList" item="itemId" separator="," open="(" close=")">
|
||||||
|
#{itemId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
<if test="request.workspaceId != null">
|
<if test="request.workspaceId != null">
|
||||||
AND project.workspace_id = #{request.workspaceId}
|
AND project.workspace_id = #{request.workspaceId}
|
||||||
</if>
|
</if>
|
||||||
|
|
|
@ -467,6 +467,12 @@
|
||||||
<if test="request.projectId != null">
|
<if test="request.projectId != null">
|
||||||
and test_case.project_id = #{request.projectId}
|
and test_case.project_id = #{request.projectId}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="request.projectIdList != null and request.projectIdList.size() > 0">
|
||||||
|
AND project.id in
|
||||||
|
<foreach collection="request.projectIdList" item="itemId" separator="," open="(" close=")">
|
||||||
|
#{itemId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
<include refid="filters"/>
|
<include refid="filters"/>
|
||||||
<if test="request.caseCoverage == 'uncoverage' ">
|
<if test="request.caseCoverage == 'uncoverage' ">
|
||||||
and test_case.id not in (select distinct test_case_test.test_case_id from test_case_test)
|
and test_case.id not in (select distinct test_case_test.test_case_id from test_case_test)
|
||||||
|
|
|
@ -4,6 +4,9 @@ import io.metersphere.request.BaseQueryRequest;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class ApiScenarioRequest extends BaseQueryRequest {
|
public class ApiScenarioRequest extends BaseQueryRequest {
|
||||||
|
@ -35,4 +38,5 @@ public class ApiScenarioRequest extends BaseQueryRequest {
|
||||||
|
|
||||||
//测试计划关联场景过滤掉步骤为0的场景
|
//测试计划关联场景过滤掉步骤为0的场景
|
||||||
private String stepTotal;
|
private String stepTotal;
|
||||||
|
private List<String> projectIdList = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import io.metersphere.request.OrderRequest;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -73,4 +74,6 @@ public class ApiTestCaseRequest extends BaseQueryRequest {
|
||||||
|
|
||||||
//全选
|
//全选
|
||||||
private boolean selectAll;
|
private boolean selectAll;
|
||||||
|
|
||||||
|
private List<String> projectIdList = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import io.metersphere.request.BaseQueryRequest;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -63,4 +64,6 @@ public class QueryTestCaseRequest extends BaseQueryRequest {
|
||||||
private Boolean toBeUpdated;
|
private Boolean toBeUpdated;
|
||||||
private String apiCoverage;
|
private String apiCoverage;
|
||||||
private String scenarioCoverage;
|
private String scenarioCoverage;
|
||||||
|
|
||||||
|
private List<String> projectIdList = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import io.metersphere.request.OrderRequest;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -15,4 +16,5 @@ public class QueryTestPlanRequest extends TestPlanRequest {
|
||||||
private List<OrderRequest> orders;
|
private List<OrderRequest> orders;
|
||||||
private Map<String, List<String>> filters;
|
private Map<String, List<String>> filters;
|
||||||
private Map<String, Object> combine;
|
private Map<String, Object> combine;
|
||||||
|
private List<String> projectIdList = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,25 +12,21 @@ import io.metersphere.commons.utils.SessionUtils;
|
||||||
import io.metersphere.request.ApiSyncCaseRequest;
|
import io.metersphere.request.ApiSyncCaseRequest;
|
||||||
import io.metersphere.request.ProjectRequest;
|
import io.metersphere.request.ProjectRequest;
|
||||||
import io.metersphere.request.api.ApiScenarioRequest;
|
import io.metersphere.request.api.ApiScenarioRequest;
|
||||||
|
import io.metersphere.request.api.ApiTestCaseRequest;
|
||||||
import io.metersphere.request.track.QueryTestCaseRequest;
|
import io.metersphere.request.track.QueryTestCaseRequest;
|
||||||
import io.metersphere.request.track.QueryTestPlanRequest;
|
import io.metersphere.request.track.QueryTestPlanRequest;
|
||||||
import io.metersphere.request.api.ApiTestCaseRequest;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.time.DayOfWeek;
|
import java.time.DayOfWeek;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.temporal.TemporalAccessor;
|
|
||||||
import java.time.temporal.TemporalField;
|
import java.time.temporal.TemporalField;
|
||||||
import java.time.temporal.WeekFields;
|
import java.time.temporal.WeekFields;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import static io.metersphere.workstation.util.ShareUtil.getTimeMills;
|
import static io.metersphere.workstation.util.ShareUtil.getTimeMills;
|
||||||
|
|
||||||
|
@ -77,7 +73,7 @@ public class WorkstationService {
|
||||||
createTime = startDayOfWeek.getTime();
|
createTime = startDayOfWeek.getTime();
|
||||||
}
|
}
|
||||||
String userId = SessionUtils.getUserId();
|
String userId = SessionUtils.getUserId();
|
||||||
//build query condition object
|
|
||||||
QueryTestPlanRequest testPlanRequest = new QueryTestPlanRequest();
|
QueryTestPlanRequest testPlanRequest = new QueryTestPlanRequest();
|
||||||
testPlanRequest.setUserId(userId);
|
testPlanRequest.setUserId(userId);
|
||||||
testPlanRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
testPlanRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||||
|
@ -89,7 +85,7 @@ public class WorkstationService {
|
||||||
if (isWeek) {
|
if (isWeek) {
|
||||||
apiTestCaseRequest.setCreateTime(createTime);
|
apiTestCaseRequest.setCreateTime(createTime);
|
||||||
}
|
}
|
||||||
//@see io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml:103
|
|
||||||
Map<String, Object> combine = new HashMap<>(2);
|
Map<String, Object> combine = new HashMap<>(2);
|
||||||
Map<String, String> operatorValue = new HashMap<>(2);
|
Map<String, String> operatorValue = new HashMap<>(2);
|
||||||
operatorValue.put("operator", "current user");
|
operatorValue.put("operator", "current user");
|
||||||
|
@ -109,6 +105,19 @@ public class WorkstationService {
|
||||||
if (isWeek) {
|
if (isWeek) {
|
||||||
testCaseRequest.setCreateTime(createTime);
|
testCaseRequest.setCreateTime(createTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProjectRequest projectRequest = new ProjectRequest();
|
||||||
|
projectRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||||
|
projectRequest.setUserId(userId);
|
||||||
|
List<Project> projects = baseProjectMapper.getUserProject(projectRequest);
|
||||||
|
if (CollectionUtils.isNotEmpty(projects)) {
|
||||||
|
List<String> projectIds = projects.stream().map(Project::getId).toList();
|
||||||
|
apiScenarioRequest.setProjectIdList(projectIds);
|
||||||
|
apiTestCaseRequest.setProjectIdList(projectIds);
|
||||||
|
testCaseRequest.setProjectIdList(projectIds);
|
||||||
|
testPlanRequest.setProjectIdList(projectIds);
|
||||||
|
}
|
||||||
|
|
||||||
//query db
|
//query db
|
||||||
int apiScenarioCaseCount = extApiScenarioMapper.listModule(apiScenarioRequest);
|
int apiScenarioCaseCount = extApiScenarioMapper.listModule(apiScenarioRequest);
|
||||||
int apiTestCaseCount = extApiTestCaseMapper.moduleCount(apiTestCaseRequest);
|
int apiTestCaseCount = extApiTestCaseMapper.moduleCount(apiTestCaseRequest);
|
||||||
|
@ -124,12 +133,17 @@ public class WorkstationService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Integer> getFollowTotalCount(String workstationId){
|
public Map<String, Integer> getFollowTotalCount(String workstationId) {
|
||||||
String userId = SessionUtils.getUserId();
|
String userId = SessionUtils.getUserId();
|
||||||
List<String> projectIds = extProjectMapper.getProjectIdByWorkspaceId(workstationId);
|
|
||||||
if (CollectionUtils.isEmpty(projectIds)) {
|
ProjectRequest projectRequest = new ProjectRequest();
|
||||||
|
projectRequest.setWorkspaceId(workstationId);
|
||||||
|
projectRequest.setUserId(userId);
|
||||||
|
List<Project> projects = baseProjectMapper.getUserProject(projectRequest);
|
||||||
|
if (CollectionUtils.isEmpty(projects)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
List<String> projectIds = projects.stream().map(Project::getId).toList();
|
||||||
int caseFollowCount = extTestCaseMapper.getCountFollow(projectIds, userId);
|
int caseFollowCount = extTestCaseMapper.getCountFollow(projectIds, userId);
|
||||||
int planFollowCount = extTestPlanMapper.getCountFollow(projectIds, userId);
|
int planFollowCount = extTestPlanMapper.getCountFollow(projectIds, userId);
|
||||||
int reviewFollowCount = extTestCaseReviewMapper.getCountFollow(projectIds, userId);
|
int reviewFollowCount = extTestCaseReviewMapper.getCountFollow(projectIds, userId);
|
||||||
|
@ -246,10 +260,14 @@ public class WorkstationService {
|
||||||
|
|
||||||
public Integer getIssueWeekCount(String workstationId) {
|
public Integer getIssueWeekCount(String workstationId) {
|
||||||
String userId = SessionUtils.getUserId();
|
String userId = SessionUtils.getUserId();
|
||||||
List<String> projectIds = extProjectMapper.getProjectIdByWorkspaceId(workstationId);
|
ProjectRequest projectRequest = new ProjectRequest();
|
||||||
if (CollectionUtils.isEmpty(projectIds)) {
|
projectRequest.setWorkspaceId(workstationId);
|
||||||
|
projectRequest.setUserId(userId);
|
||||||
|
List<Project> projects = baseProjectMapper.getUserProject(projectRequest);
|
||||||
|
if (CollectionUtils.isEmpty(projects)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
List<String> projectIds = projects.stream().map(Project::getId).toList();
|
||||||
Date startDayOfWeek = getStartDayOfWeek();
|
Date startDayOfWeek = getStartDayOfWeek();
|
||||||
Long createTime = startDayOfWeek.getTime();
|
Long createTime = startDayOfWeek.getTime();
|
||||||
return extIssuesMapper.getCountCreat(projectIds, userId, createTime);
|
return extIssuesMapper.getCountCreat(projectIds, userId, createTime);
|
||||||
|
|
Loading…
Reference in New Issue