#23-Create new methods

This commit is contained in:
Anton Romanov 2021-04-16 14:53:38 +04:00
parent 6304365ec6
commit 0b41ef37ae

View File

@ -25,49 +25,74 @@ public class StatisticController {
@GetMapping(STATISTIC)
public String indexBranch(Model model) {
List<Object[]> authorCommits = commitRepository.getCommitAuthorStatistic().stream()
.map(stat -> new Object[]{stat.getAuthor(), stat.getCountCommit()})
.collect(Collectors.toList());
model.addAttribute("commitAuthorData", authorCommits);
List<Object[]> urlCommits = commitRepository.getCommitUrlStatistic().stream()
.map(stat -> new Object[]{stat.getUrl(), stat.getCountCommit()})
.collect(Collectors.toList());
model.addAttribute("commitUrlData", urlCommits);
List<Object[]> timeCommits = commitRepository.getCommitTimeStatistic().stream()
.map(stat -> new Object[]{stat.getDate(), stat.getCountCommit()})
.collect(Collectors.toList());
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("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);
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);
List<Object[]> entityCommits = commitRepository.getCommitEntityStatistic().stream()
.map(stat -> new Object[]{stat.getEntity(), stat.getCountCommit()})
.collect(Collectors.toList());
for (int i = 0; i < entityCommits.size(); i++) {
entityCommits.get(i)[0] = Boolean.TRUE.equals(entityCommits.get(i)[0])
for (int i = 0; i < entityCommits().size(); i++) {
entityCommits().get(i)[0] = Boolean.TRUE.equals(entityCommits().get(i)[0])
? "Есть сущности"
: (entityCommits.get(i)[0] == null
: (entityCommits().get(i)[0] == null
? "Нет данных"
: "Нет сущностей");
}
model.addAttribute("commitEntityData", entityCommits);
model.addAttribute("commitEntityData", entityCommits());
model.addAttribute("commitTimeEntityData", allTimeEntityCommits());
return STATISTIC;
}
public List<Object[]> authorCommits() {
List<Object[]> authorCommits = commitRepository.getCommitAuthorStatistic().stream()
.map(stat -> new Object[]{stat.getAuthor(), stat.getCountCommit()})
.collect(Collectors.toList());
return authorCommits;
}
public List<Object[]> urlCommits() {
List<Object[]> urlCommits = commitRepository.getCommitUrlStatistic().stream()
.map(stat -> new Object[]{stat.getUrl(), stat.getCountCommit()})
.collect(Collectors.toList());
return urlCommits;
}
public List<Object[]> timeCommits() {
List<Object[]> timeCommits = commitRepository.getCommitTimeStatistic().stream()
.map(stat -> new Object[]{stat.getDate(), stat.getCountCommit()})
.collect(Collectors.toList());
return timeCommits;
}
public List<Object[]> entityCommits() {
List<Object[]> entityCommits = commitRepository.getCommitEntityStatistic().stream()
.map(stat -> new Object[]{stat.getEntity(), stat.getCountCommit()})
.collect(Collectors.toList());
return entityCommits;
}
public List<Object[]> timeEntityCommits() {
List<Object[]> timeEntityCommits = commitRepository.getCommitTimeEntityStatistic().stream()
.map(stat -> new Object[]{stat.getDate(), stat.getCountCommit()})
.collect(Collectors.toList());
return timeEntityCommits;
}
public List<Object[]> allTimeEntityCommits() {
List<Object[]> allTimeEntityCommits = commitRepository.getCommitTimeStatistic().stream()
.map(stat -> new Object[]{stat.getDate(), stat.getCountCommit()})
.collect(Collectors.toList());
int j = 0;
for (int i = 0; i < allTimeEntityCommits.size(); i++) {
if ((j < timeEntityCommits.size()) && (allTimeEntityCommits.get(i)[0].equals(timeEntityCommits.get(j)[0]))) {
allTimeEntityCommits.get(i)[1] = timeEntityCommits.get(j)[1];
if ((j < timeEntityCommits().size()) && (allTimeEntityCommits.get(i)[0].equals(timeEntityCommits().get(j)[0]))) {
allTimeEntityCommits.get(i)[1] = timeEntityCommits().get(j)[1];
j++;
} else {
if (i > 0) {
@ -75,7 +100,6 @@ public class StatisticController {
}
}
}
model.addAttribute("commitTimeEntityData", allTimeEntityCommits);
return STATISTIC;
return allTimeEntityCommits;
}
}