Skip to content

Commit

Permalink
Queries updated
Browse files Browse the repository at this point in the history
  • Loading branch information
gitorko committed Jan 19, 2016
1 parent 56eeb9f commit 3c9ab5c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/main/java/com/deem/excord/controller/HomeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ public String home(Model model, HttpSession session) {
Long coveragePercentage = Math.round(((totalReqCnt - missCnt) * 100.0) / totalReqCnt);

Integer automationCnt = tcDao.automationCnt();
Long testcaseCnt = tcDao.count();
Integer testcaseCnt = tcDao.getCountOfActiveTestcases();
Long automationPercentage = Math.round((automationCnt * 100.0) / testcaseCnt);

model.addAttribute("tcCnt", testcaseCnt);
model.addAttribute("tpCnt", tpDao.count());
model.addAttribute("rCnt", rDao.count());
model.addAttribute("trCnt", trDao.count());
model.addAttribute("tpCnt", tpDao.getCountOfActiveTestplan());
model.addAttribute("rCnt", rDao.getCountOfActiveRequirements());
model.addAttribute("trCnt", trDao.getCountOfExecutionByYear());
model.addAttribute("coveragePercentage", coveragePercentage);
model.addAttribute("automationPercentage", automationPercentage);
return "home";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ public interface RequirementRepository extends CrudRepository<EcRequirement, Lon

public EcRequirement findByIdAndParentId(Long id, EcRequirement parentRequirement);

@Query(value = "SELECT count(*) FROM ec_requirement where STATUS = 'ACTIVE' and coverage = 1", nativeQuery = true)
public Integer getCountOfActiveRequirements();

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ public interface TestCaseRepository extends CrudRepository<EcTestcase, Long> {
@Query(value = "SELECT count(*) FROM ec_testcase where automated = true", nativeQuery = true)
public Integer automationCnt();

@Query(value = "SELECT count(*) FROM ec_testcase where enabled = 1", nativeQuery = true)
public Integer getCountOfActiveTestcases();

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ public interface TestPlanRepository extends CrudRepository<EcTestplan, Long> {
@Query(value = "select priority,assigned_to,status,SUM(cnt) from (SELECT b.priority,a.assigned_to,'NOT_RUN' as `status`,count(*) as cnt FROM ec_testcase b, ec_testplan_testcase_mapping a LEFT JOIN ec_testresult c ON a.id = c.testplan_testcase_link_id where a.testplan_id = :testplanId and a.testcase_id = b.id and c.status is null group by a.assigned_to,b.priority UNION ALL SELECT b.priority,a.assigned_to,c.`status`,count(*) as cnt FROM ec_testcase b, ec_testplan_testcase_mapping a,ec_testresult c where a.id = c.testplan_testcase_link_id and a.testplan_id = :testplanId and a.testcase_id = b.id and c.latest = 1 group by a.assigned_to,b.priority,c.status ) as tab1 group by assigned_to,priority,status order by assigned_to,priority,status", nativeQuery = true)
public List<Object[]> findByPriorityByTester(@Param("testplanId") Long testplanId);

@Query(value = "SELECT count(*) FROM ec_testplan where enabled = 1", nativeQuery = true)
public Integer getCountOfActiveTestplan();

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ public interface TestResultRepository extends CrudRepository<EcTestresult, Long>

@Query(value = "select DATE_FORMAT(`timestamp`,'%m-%Y'),count(*) from ec_testresult where DATE_FORMAT(`timestamp`,'%Y') = DATE_FORMAT(NOW(),'%Y') group by DATE_FORMAT(`timestamp`,'%m-%Y') order by DATE_FORMAT(`timestamp`,'%m-%Y') asc", nativeQuery = true)
public List<Object[]> executionByMonth();

@Query(value = "SELECT count(*) FROM excord.ec_testresult where latest = 1 and YEAR(timestamp) = YEAR(NOW())", nativeQuery = true)
public Integer getCountOfExecutionByYear();
}
6 changes: 3 additions & 3 deletions src/main/resources/templates/home.ftl.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
<div class="row">
<div class="col-md-6">
<div class="jumbotron well well-lg">
<h2>Requirements: ${rCnt}</h2>
<h2>Active Requirements: ${rCnt}</h2>
</div>
</div>
<div class="col-md-6">
<div class="jumbotron well well-lg">
<h2>Testplans: ${tpCnt}</h2>
<h2>Active Testplans: ${tpCnt}</h2>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="jumbotron well well-lg">
<h2>Testcases: ${tcCnt}</h2>
<h2>Active Testcases: ${tcCnt}</h2>
</div>
</div>
<div class="col-md-6">
Expand Down

0 comments on commit 3c9ab5c

Please sign in to comment.