#27 -- fix statistic

This commit is contained in:
Anton Romanov 2021-04-29 16:19:27 +04:00
parent 97433f9e73
commit 49e906c190

View File

@ -27,19 +27,20 @@ public class StatisticController {
@GetMapping(STATISTIC)
public String indexBranch(Model model) {
List<Object[]> urlCommits = getUrlCommits();
List<Object[]> timeCommits = getTimeCommits();
model.addAttribute("commitAuthorData", authorCommits());
model.addAttribute("commitUrlData", urlCommits());
model.addAttribute("commitTimeData", timeCommits());
String[] date = new String[timeCommits().size()];
for (int i = 0; i < timeCommits().size(); i++) {
date[i] = timeCommits().get(i)[0].toString();
}
model.addAttribute("dates", date);
String[] url = new String[urlCommits().size()];
for (int i = 0; i < urlCommits().size(); i++) {
url[i] = urlCommits().get(i)[0].toString().substring(urlCommits().get(i)[0].toString().lastIndexOf("/") + 1);
}
model.addAttribute("urls", url);
model.addAttribute("commitUrlData", urlCommits);
model.addAttribute("commitTimeData", timeCommits);
List<String> dates = timeCommits.stream()
.map(tc -> tc[0].toString())
.collect(Collectors.toList());
model.addAttribute("dates", dates);
List<String> urls = urlCommits.stream()
.map(tc -> tc[0].toString().substring(tc[0].toString().lastIndexOf("/") + 1))
.collect(Collectors.toList());
model.addAttribute("urls", urls);
model.addAttribute("commitEntityData", entityCommits());
model.addAttribute("commitTimeEntityData", allTimeEntityCommits());
return STATISTIC;
@ -52,14 +53,14 @@ public class StatisticController {
return authorCommits;
}
public List<Object[]> urlCommits() {
public List<Object[]> getUrlCommits() {
List<Object[]> urlCommits = commitRepository.getCommitUrlStatistic().stream()
.map(stat -> new Object[]{stat.getUrl(), stat.getCountCommit()})
.collect(Collectors.toList());
return urlCommits;
}
public List<Object[]> timeCommits() {
public List<Object[]> getTimeCommits() {
List<Object[]> timeCommits = commitRepository.getCommitTimeStatistic().stream()
.map(stat -> new Object[]{stat.getDate(), stat.getCountCommit()})
.collect(Collectors.toList());