未验证 提交 3756a233 编写于 作者: W WangJPLeo 提交者: GitHub

[Fix-10863] Command execution result data statistics remove userId condition. (#10864)

* Command execution result data statistics remove userId condition.

* e2e rerun
上级 59829048
......@@ -258,15 +258,13 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
return result;
}
Long[] projectCodeArray = getProjectCodesArrays(projectIds.getLeft());
int userId = loginUser.getUserType() == UserType.ADMIN_USER ? 0 : loginUser.getId();
// count normal command state
Map<CommandType, Integer> normalCountCommandCounts = commandMapper.countCommandState(userId, start, end, projectCodeArray)
Map<CommandType, Integer> normalCountCommandCounts = commandMapper.countCommandState(start, end, projectCodeArray)
.stream()
.collect(Collectors.toMap(CommandCount::getCommandType, CommandCount::getCount));
// count error command state
Map<CommandType, Integer> errorCommandCounts = errorCommandMapper.countCommandState(userId, start, end, projectCodeArray)
Map<CommandType, Integer> errorCommandCounts = errorCommandMapper.countCommandState(start, end, projectCodeArray)
.stream()
.collect(Collectors.toMap(CommandCount::getCommandType, CommandCount::getCount));
......
......@@ -36,7 +36,6 @@ public class AccessLogAspectTest {
String actual = accessLogAspect.handleSensitiveData(data);
Assert.assertEquals(expected, actual);
}
}
......@@ -290,15 +290,15 @@ public class DataAnalysisServiceTest {
CommandCount commandCount = new CommandCount();
commandCount.setCommandType(CommandType.START_PROCESS);
commandCounts.add(commandCount);
Mockito.when(commandMapper.countCommandState(0, null, null, new Long[]{1L})).thenReturn(commandCounts);
Mockito.when(errorCommandMapper.countCommandState(0, null, null, new Long[]{1L})).thenReturn(commandCounts);
Mockito.when(commandMapper.countCommandState(null, null, new Long[]{1L})).thenReturn(commandCounts);
Mockito.when(errorCommandMapper.countCommandState(null, null, new Long[]{1L})).thenReturn(commandCounts);
Map<String, Object> result = dataAnalysisServiceImpl.countCommandState(user);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
// when no command found then return all count are 0
Mockito.when(commandMapper.countCommandState(anyInt(), any(), any(), any())).thenReturn(Collections.emptyList());
Mockito.when(errorCommandMapper.countCommandState(anyInt(), any(), any(), any())).thenReturn(Collections.emptyList());
Mockito.when(commandMapper.countCommandState(any(), any(), any())).thenReturn(Collections.emptyList());
Mockito.when(errorCommandMapper.countCommandState(any(), any(), any())).thenReturn(Collections.emptyList());
Mockito.when(resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.PROJECTS, 1, serviceLogger)).thenReturn(projectIds());
Map<String, Object> result5 = dataAnalysisServiceImpl.countCommandState(user);
......@@ -313,8 +313,8 @@ public class DataAnalysisServiceTest {
CommandCount errorCommandCount = new CommandCount();
errorCommandCount.setCommandType(CommandType.START_PROCESS);
errorCommandCount.setCount(5);
Mockito.when(commandMapper.countCommandState(anyInt(), any(), any(), any())).thenReturn(Collections.singletonList(normalCommandCount));
Mockito.when(errorCommandMapper.countCommandState(anyInt(), any(), any(), any())).thenReturn(Collections.singletonList(errorCommandCount));
Mockito.when(commandMapper.countCommandState(any(), any(), any())).thenReturn(Collections.singletonList(normalCommandCount));
Mockito.when(errorCommandMapper.countCommandState(any(), any(), any())).thenReturn(Collections.singletonList(errorCommandCount));
Map<String, Object> result6 = dataAnalysisServiceImpl.countCommandState(user);
......
......@@ -34,14 +34,12 @@ public interface CommandMapper extends BaseMapper<Command> {
/**
* count command state
* @param userId userId
* @param startTime startTime
* @param endTime endTime
* @param projectCodeArray projectCodeArray
* @return CommandCount list
*/
List<CommandCount> countCommandState(
@Param("userId") int userId,
@Param("startTime") Date startTime,
@Param("endTime") Date endTime,
@Param("projectCodeArray") Long[] projectCodeArray);
......
......@@ -34,14 +34,12 @@ public interface ErrorCommandMapper extends BaseMapper<ErrorCommand> {
/**
* count command state
* @param userId
* @param startTime startTime
* @param endTime endTime
* @param projectCodeArray projectCodeArray
* @return CommandCount list
*/
List<CommandCount> countCommandState(
@Param("userId") int userId,
@Param("startTime") Date startTime,
@Param("endTime") Date endTime,
@Param("projectCodeArray") Long[] projectCodeArray);
......
......@@ -22,9 +22,6 @@
select cmd.command_type as command_type, count(1) as count
from t_ds_command cmd, t_ds_process_definition process
where cmd.process_definition_code = process.code
<if test="userId != 0 ">
and process.user_id= #{userId}
</if>
<if test="projectCodeArray != null and projectCodeArray.length != 0">
and process.project_code in
<foreach collection="projectCodeArray" index="index" item="i" open="(" close=")" separator=",">
......
......@@ -22,9 +22,6 @@
select cmd.command_type as command_type, count(1) as count
from t_ds_error_command cmd, t_ds_process_definition process
where cmd.process_definition_code = process.code
<if test="userId != 0 ">
and process.user_id= #{userId}
</if>
<if test="projectCodeArray != null and projectCodeArray.length != 0">
and process.project_code in
<foreach collection="projectCodeArray" index="index" item="i" open="(" close=")" separator=",">
......
......@@ -162,7 +162,7 @@ public class CommandMapperTest extends BaseDaoTest {
Date endTime = DateUtils.stringToDate("2019-12-29 23:59:59");
List<CommandCount> actualCommandCounts = commandMapper.countCommandState(0, startTime, endTime, projectCodeArray);
List<CommandCount> actualCommandCounts = commandMapper.countCommandState(startTime, endTime, projectCodeArray);
assertThat(actualCommandCounts.size(),greaterThanOrEqualTo(1));
}
......
......@@ -77,7 +77,6 @@ public class ErrorCommandMapperTest extends BaseDaoTest {
errorCommandMapper.updateById(errorCommand);
List<CommandCount> commandCounts = errorCommandMapper.countCommandState(
0,
null,
null,
new Long[0]
......@@ -87,7 +86,6 @@ public class ErrorCommandMapperTest extends BaseDaoTest {
projectCodeArray[0] = processDefinition.getProjectCode();
projectCodeArray[1] = 200L;
List<CommandCount> commandCounts2 = errorCommandMapper.countCommandState(
0,
null,
null,
projectCodeArray
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册