Search in sources :

Example 1 with StatProjectResult

use of com.ibeiliao.deployment.admin.vo.stat.StatProjectResult in project Corgi by kevinYin.

the class StatServiceImpl method statProjectAndSave.

private void statProjectAndSave(Date startTime, Date endTime) {
    List<StatProjectResult> projectResults = deployHistoryService.statProject(startTime, endTime);
    Map<Integer, StatProjectPO> projectStatMap = new HashMap<>();
    for (StatProjectResult spr : projectResults) {
        StatProjectPO statProject = projectStatMap.get(spr.getProjectId());
        if (statProject == null) {
            statProject = new StatProjectPO();
            statProject.setEnvId(spr.getEnvId());
            statProject.setStatDate(startTime);
            statProject.setProjectId(spr.getProjectId());
            projectStatMap.put(spr.getProjectId(), statProject);
        }
        statProject.setDeployTimes(statProject.getDeployTimes() + spr.getNum());
        if (spr.getResult() == DeployResult.SUCCESS.getValue()) {
            statProject.setSuccess(statProject.getSuccess() + spr.getNum());
        } else {
            // 其他都算做失败,包括部分成功的
            statProject.setFailure(statProject.getFailure() + spr.getNum());
        }
    }
    Collection<StatProjectPO> statProjects = projectStatMap.values();
    if (statProjects.isEmpty()) {
        logger.warn("没有发布数据");
        return;
    }
    statProjectDao.deleteByDate(startTime);
    statProjectDao.batchInsertOrUpdate(statProjects);
    saveStatAll(startTime, statProjects);
}
Also used : StatProjectPO(com.ibeiliao.deployment.admin.po.stat.StatProjectPO) StatProjectResult(com.ibeiliao.deployment.admin.vo.stat.StatProjectResult)

Example 2 with StatProjectResult

use of com.ibeiliao.deployment.admin.vo.stat.StatProjectResult in project Corgi by kevinYin.

the class DeployHistoryDaoTest method testStatProject.

/**
 * 仅测试语法,不测试逻辑
 */
@Test
public void testStatProject() {
    Date startTime = DateUtil.currentStartDate();
    Date endTime = DateUtil.currentEndDate();
    List<StatProjectResult> list = deployHistoryDao.statProject(startTime, endTime, DeployStatus.DEPLOYED.getValue());
    assertNotNull(list);
}
Also used : StatProjectResult(com.ibeiliao.deployment.admin.vo.stat.StatProjectResult) Date(java.util.Date) Test(org.junit.Test)

Aggregations

StatProjectResult (com.ibeiliao.deployment.admin.vo.stat.StatProjectResult)2 StatProjectPO (com.ibeiliao.deployment.admin.po.stat.StatProjectPO)1 Date (java.util.Date)1 Test (org.junit.Test)1