|
|
|
@ -1,3 +1,8 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
|
|
|
|
|
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package ru.ulstu.extractor.controller;
|
|
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
@ -24,28 +29,11 @@ public class StatisticController {
|
|
|
|
|
"Europe", "North America", "Sourth America"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model.addAttribute("continents", continents);
|
|
|
|
|
model.addAttribute("array", new int[]{1, 2, 3});
|
|
|
|
|
List<String[]> listArr = commitRepository.getCommitAuthorStatistic().stream()
|
|
|
|
|
.map(stat -> new String[]{stat.getAuthor(), stat.getCountCommit().toString()})
|
|
|
|
|
List<Object[]> authorCommits = commitRepository.getCommitAuthorStatistic().stream()
|
|
|
|
|
.map(stat -> new Object[]{stat.getAuthor(), stat.getCountCommit()})
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
String[][] commitAuthorData = listArr.toArray(String[][]::new);
|
|
|
|
|
model.addAttribute("commitAuthorData", findPercent(commitAuthorData));
|
|
|
|
|
model.addAttribute("commitAuthorData", authorCommits);
|
|
|
|
|
return "statistic";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String[][] findPercent(String[][] commitAuthorData) {
|
|
|
|
|
long sum = 0;
|
|
|
|
|
for (int i = 0; i < commitAuthorData.length; i++) {
|
|
|
|
|
sum = sum + Integer.parseInt(commitAuthorData[i][1]);
|
|
|
|
|
}
|
|
|
|
|
System.out.println(sum);
|
|
|
|
|
long percent = 0;
|
|
|
|
|
for (int i = 0; i < commitAuthorData.length; i++) {
|
|
|
|
|
percent = Integer.parseInt(commitAuthorData[i][1]) * 100 / sum;
|
|
|
|
|
commitAuthorData[i][1] = "";
|
|
|
|
|
}
|
|
|
|
|
return commitAuthorData;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|