Search in sources :

Example 1 with LowQualityRankPO

use of com.ibeiliao.deployment.admin.po.stat.LowQualityRankPO in project Corgi by kevinYin.

the class LowQualityRankDaoTest method testBatchInsertAndQuery.

@Test
public void testBatchInsertAndQuery() {
    Date today = new Date();
    int module1Id = 6;
    List<LowQualityRankPO> list = new ArrayList<>();
    list.add(create(today, module1Id));
    list.add(create(today, 2));
    list.add(create(today, 3));
    list.add(create(today, 4));
    lowQualityRankDao.batchInsertOrUpdate(list);
    Date startDate = DateUtil.currentStartDate();
    Date endDate = DateUtil.currentEndDate();
    List<LowQualityRankPO> queryResult = lowQualityRankDao.queryByDate(startDate, endDate);
    assertNotNull(queryResult);
    assertTrue(queryResult.size() == 1);
    // 检查 on duplicate
    list = new ArrayList<>();
    LowQualityRankPO module1 = create(today, module1Id);
    list.add(module1);
    list.add(create(today, 2));
    lowQualityRankDao.batchInsertOrUpdate(list);
    queryResult = lowQualityRankDao.queryByDate(startDate, endDate);
    boolean found = false;
    for (LowQualityRankPO tmp : queryResult) {
        if (tmp.getModuleId() == module1Id) {
            assertTrue(tmp.getDeployTimes() == module1.getDeployTimes());
            found = true;
            break;
        }
    }
    assertTrue(found);
}
Also used : LowQualityRankPO(com.ibeiliao.deployment.admin.po.stat.LowQualityRankPO) ArrayList(java.util.ArrayList) Date(java.util.Date) Test(org.junit.Test)

Example 2 with LowQualityRankPO

use of com.ibeiliao.deployment.admin.po.stat.LowQualityRankPO in project Corgi by kevinYin.

the class StatServiceImpl method statLowQualityModule.

private void statLowQualityModule(Date startTime, Date endTime) {
    List<LowQualityRank> lowQualityRanks = deployHistoryService.statLowQualityModule(startTime, endTime);
    if (lowQualityRanks.isEmpty()) {
        logger.warn("没有发布数据");
        return;
    }
    List<LowQualityRankPO> list = new ArrayList<>(lowQualityRanks.size());
    for (LowQualityRank rank : lowQualityRanks) {
        LowQualityRankPO po = new LowQualityRankPO();
        po.setModuleId(rank.getModuleId());
        po.setDeployTimes(rank.getDeployTimes());
        po.setStatDate(startTime);
    }
    lowQualityRankDao.deleteByDate(startTime);
    lowQualityRankDao.batchInsertOrUpdate(list);
}
Also used : LowQualityRankPO(com.ibeiliao.deployment.admin.po.stat.LowQualityRankPO) LowQualityRank(com.ibeiliao.deployment.admin.vo.stat.LowQualityRank)

Example 3 with LowQualityRankPO

use of com.ibeiliao.deployment.admin.po.stat.LowQualityRankPO in project Corgi by kevinYin.

the class LowQualityRankDaoTest method create.

private LowQualityRankPO create(Date date, int moduleId) {
    LowQualityRankPO po = new LowQualityRankPO();
    po.setStatDate(date);
    po.setDeployTimes(random.nextInt(1000000));
    po.setModuleId(moduleId);
    return po;
}
Also used : LowQualityRankPO(com.ibeiliao.deployment.admin.po.stat.LowQualityRankPO)

Aggregations

LowQualityRankPO (com.ibeiliao.deployment.admin.po.stat.LowQualityRankPO)3 LowQualityRank (com.ibeiliao.deployment.admin.vo.stat.LowQualityRank)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Test (org.junit.Test)1