diff --git a/src/main/java/io/choerodon/devops/app/service/DevopsCommandEventService.java b/src/main/java/io/choerodon/devops/app/service/DevopsCommandEventService.java index 09d13f509a..419c675424 100644 --- a/src/main/java/io/choerodon/devops/app/service/DevopsCommandEventService.java +++ b/src/main/java/io/choerodon/devops/app/service/DevopsCommandEventService.java @@ -18,13 +18,13 @@ public interface DevopsCommandEventService { void baseDeleteByCommandId(Long commandId); /** - * 根据commandIds 批量查询 + * 根据commandIds 批量查询(最多查询最近200条) * * @param commandIds * @param type * @return */ - List listByCommandIdsAndType(Set commandIds, String type); + List listLastByCommandIdsAndType(Set commandIds, String type); /** * 根据commandIds 批量查询 diff --git a/src/main/java/io/choerodon/devops/app/service/impl/DevopsCommandEventServiceImpl.java b/src/main/java/io/choerodon/devops/app/service/impl/DevopsCommandEventServiceImpl.java index 09c1d6b4e6..09a24884f1 100644 --- a/src/main/java/io/choerodon/devops/app/service/impl/DevopsCommandEventServiceImpl.java +++ b/src/main/java/io/choerodon/devops/app/service/impl/DevopsCommandEventServiceImpl.java @@ -53,7 +53,7 @@ public void baseDeleteByCommandId(Long commandId) { } @Override - public List listByCommandIdsAndType(Set commandIds, String type) { + public List listLastByCommandIdsAndType(Set commandIds, String type) { return commandIds.isEmpty() ? new ArrayList<>() : devopsCommandEventMapper.listByCommandIdsAndType(commandIds, type); } diff --git a/src/main/java/io/choerodon/devops/app/service/impl/DevopsEnvResourceServiceImpl.java b/src/main/java/io/choerodon/devops/app/service/impl/DevopsEnvResourceServiceImpl.java index 3731ded5f6..4c1a080cc5 100644 --- a/src/main/java/io/choerodon/devops/app/service/impl/DevopsEnvResourceServiceImpl.java +++ b/src/main/java/io/choerodon/devops/app/service/impl/DevopsEnvResourceServiceImpl.java @@ -208,8 +208,8 @@ private List listEventByObjectId(Long objectId, ObjectType obje // 查出所有的 DevopsCommandEventDTO 并根据commandId分组 Set commandIds = devopsEnvCommandDTOS.stream().map(DevopsEnvCommandDTO::getId).collect(Collectors.toSet()); - List commandEventTypeJob = devopsCommandEventService.listByCommandIdsAndType(commandIds, ResourceType.JOB.getType()); - List commandEventTypePod = devopsCommandEventService.listByCommandIdsAndType(commandIds, ResourceType.POD.getType()); + List commandEventTypeJob = devopsCommandEventService.listLastByCommandIdsAndType(commandIds, ResourceType.JOB.getType()); + List commandEventTypePod = devopsCommandEventService.listLastByCommandIdsAndType(commandIds, ResourceType.POD.getType()); Map> commandEventTypeJobMap = commandEventTypeJob.stream().collect(Collectors.groupingBy(DevopsCommandEventDTO::getCommandId)); Map> commandEventTypePodJobMap = commandEventTypePod.stream().collect(Collectors.groupingBy(DevopsCommandEventDTO::getCommandId)); diff --git a/src/main/resources/mapper/DevopsCommandEventMapper.xml b/src/main/resources/mapper/DevopsCommandEventMapper.xml index 2d52daa7c8..3ec33b057f 100644 --- a/src/main/resources/mapper/DevopsCommandEventMapper.xml +++ b/src/main/resources/mapper/DevopsCommandEventMapper.xml @@ -27,5 +27,7 @@ #{commandId} + order by id desc + limit 200 \ No newline at end of file