Skip to content

Commit

Permalink
[IMP] 调整查询pod事件逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
王灏 authored and 李浩 committed Apr 17, 2024
1 parent 4bfa4d5 commit 10788b8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ public interface DevopsCommandEventService {
void baseDeleteByCommandId(Long commandId);

/**
* 根据commandIds 批量查询
* 根据commandIds 批量查询(最多查询最近200条)
*
* @param commandIds
* @param type
* @return
*/
List<DevopsCommandEventDTO> listByCommandIdsAndType(Set<Long> commandIds, String type);
List<DevopsCommandEventDTO> listLastByCommandIdsAndType(Set<Long> commandIds, String type);

/**
* 根据commandIds 批量查询
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void baseDeleteByCommandId(Long commandId) {
}

@Override
public List<DevopsCommandEventDTO> listByCommandIdsAndType(Set<Long> commandIds, String type) {
public List<DevopsCommandEventDTO> listLastByCommandIdsAndType(Set<Long> commandIds, String type) {
return commandIds.isEmpty() ? new ArrayList<>() : devopsCommandEventMapper.listByCommandIdsAndType(commandIds, type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ private List<InstanceEventVO> listEventByObjectId(Long objectId, ObjectType obje

// 查出所有的 DevopsCommandEventDTO 并根据commandId分组
Set<Long> commandIds = devopsEnvCommandDTOS.stream().map(DevopsEnvCommandDTO::getId).collect(Collectors.toSet());
List<DevopsCommandEventDTO> commandEventTypeJob = devopsCommandEventService.listByCommandIdsAndType(commandIds, ResourceType.JOB.getType());
List<DevopsCommandEventDTO> commandEventTypePod = devopsCommandEventService.listByCommandIdsAndType(commandIds, ResourceType.POD.getType());
List<DevopsCommandEventDTO> commandEventTypeJob = devopsCommandEventService.listLastByCommandIdsAndType(commandIds, ResourceType.JOB.getType());
List<DevopsCommandEventDTO> commandEventTypePod = devopsCommandEventService.listLastByCommandIdsAndType(commandIds, ResourceType.POD.getType());
Map<Long, List<DevopsCommandEventDTO>> commandEventTypeJobMap = commandEventTypeJob.stream().collect(Collectors.groupingBy(DevopsCommandEventDTO::getCommandId));
Map<Long, List<DevopsCommandEventDTO>> commandEventTypePodJobMap = commandEventTypePod.stream().collect(Collectors.groupingBy(DevopsCommandEventDTO::getCommandId));

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/mapper/DevopsCommandEventMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@
<foreach collection="commandIds" item="commandId" open="(" separator=" , " close=")">
#{commandId}
</foreach>
order by id desc
limit 200
</select>
</mapper>

0 comments on commit 10788b8

Please sign in to comment.