|
|
@@ -218,33 +218,43 @@ public class DeployStatImpl implements DeployStat {
|
|
|
@Override
|
|
|
public PageList<AppRunningVO> getByPage(String env, String appType, int pageNumber, int pageSize) {
|
|
|
PageRequest pageRequest = PageRequest.of(pageNumber-1, pageSize);
|
|
|
- Page<AppDeploying> page = Page.empty();
|
|
|
- List<AppRunningVO> list2 = page.getContent().stream().map(appDeploying -> {
|
|
|
- AppConfig appConfig = appDeploying.getDeployingNodes().get(0).getDeployConfig().getAppConfig();
|
|
|
+ Page<AppDeploying> page = deployingRepository.findAllByAppConfig_EnvAndAppConfig_AppType(env, appType, pageRequest);
|
|
|
+ List<AppRunningVO> list = page.getContent().stream().map(appDeploying -> {
|
|
|
+ List<AppDeployingNode> deployingNodes = appDeploying.getDeployingNodes();
|
|
|
+ if (deployingNodes.isEmpty()) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
+ AppConfig appConfig = deployingNodes.get(0).getDeployConfig().getAppConfig();
|
|
|
String appId = appConfig.getAppId();
|
|
|
String appName = appConfig.getAppName();
|
|
|
String bindPorts = appConfig.getBindPorts();
|
|
|
- String packagePath = "";
|
|
|
+
|
|
|
+ String packagePath = "N/A";
|
|
|
BuildLog buildLog = appDeploying.getBuildLog();
|
|
|
if (buildLog != null) {
|
|
|
packagePath = buildLog.getPackagePath();
|
|
|
}
|
|
|
- int totalDeployed = 0;
|
|
|
- return new AppRunningVO(appId, appName, bindPorts, packagePath, totalDeployed);
|
|
|
- }).collect(Collectors.toList());
|
|
|
|
|
|
- return PageList.pageList(pageNumber, pageSize, (int) page.getTotalElements(), list2);
|
|
|
+ int totalDeployed = deployingNodes.size();
|
|
|
+ return new AppRunningVO(appId, appName, bindPorts, packagePath, totalDeployed);
|
|
|
+ }).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ return PageList.pageList(pageNumber, pageSize, (int) page.getTotalElements(), list);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<AppRunning> getAppRunning(String appId) {
|
|
|
- return Collections.emptyList();
|
|
|
- /*return deployingRepository.findAllByAppDeployConfig_AppConfig_AppId(appId).stream()
|
|
|
- //.filter(AppDeploying::isDeployed)
|
|
|
- //.sorted(Comparator.comparing(AppDeploying::getDeployTime).reversed())
|
|
|
- .map(AppRunning::new)
|
|
|
- .collect(Collectors.toList());*/
|
|
|
+ AppDeploying appDeploying = deployingRepository.findByAppConfig_AppId(appId);
|
|
|
+ if (appDeploying == null) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ BuildLog buildLog = appDeploying.getBuildLog();
|
|
|
+ return appDeploying.getDeployingNodes().stream()
|
|
|
+ .map(appDeployingNode -> new AppRunning(appDeployingNode, buildLog))
|
|
|
+ /*.filter(AppDeploying::isDeployed)
|
|
|
+ .sorted(Comparator.comparing(AppDeploying::getDeployTime).reversed())*/
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
@Override
|