Merge branch '23-create-method' into 'master'
Resolve "Создать методы для статистики" Closes #23 See merge request romanov73/git-extractor!21
This commit is contained in:
commit
6fd0a6bc9c
@ -27,28 +27,46 @@ public class StatisticController {
|
|||||||
|
|
||||||
@GetMapping(STATISTIC)
|
@GetMapping(STATISTIC)
|
||||||
public String indexBranch(Model model) {
|
public String indexBranch(Model model) {
|
||||||
|
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("commitEntityData", entityCommits());
|
||||||
|
model.addAttribute("commitTimeEntityData", allTimeEntityCommits());
|
||||||
|
return STATISTIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Object[]> authorCommits() {
|
||||||
List<Object[]> authorCommits = commitRepository.getCommitAuthorStatistic().stream()
|
List<Object[]> authorCommits = commitRepository.getCommitAuthorStatistic().stream()
|
||||||
.map(stat -> new Object[]{stat.getAuthor(), stat.getCountCommit()})
|
.map(stat -> new Object[]{stat.getAuthor(), stat.getCountCommit()})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
model.addAttribute("commitAuthorData", authorCommits);
|
return authorCommits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Object[]> urlCommits() {
|
||||||
List<Object[]> urlCommits = commitRepository.getCommitUrlStatistic().stream()
|
List<Object[]> urlCommits = commitRepository.getCommitUrlStatistic().stream()
|
||||||
.map(stat -> new Object[]{stat.getUrl(), stat.getCountCommit()})
|
.map(stat -> new Object[]{stat.getUrl(), stat.getCountCommit()})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
model.addAttribute("commitUrlData", urlCommits);
|
return urlCommits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Object[]> timeCommits() {
|
||||||
List<Object[]> timeCommits = commitRepository.getCommitTimeStatistic().stream()
|
List<Object[]> timeCommits = commitRepository.getCommitTimeStatistic().stream()
|
||||||
.map(stat -> new Object[]{stat.getDate(), stat.getCountCommit()})
|
.map(stat -> new Object[]{stat.getDate(), stat.getCountCommit()})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
model.addAttribute("commitTimeData", timeCommits);
|
return timeCommits;
|
||||||
String[] date = new String[timeCommits.size()];
|
}
|
||||||
for (int i = 0; i < timeCommits.size(); i++) {
|
|
||||||
date[i] = timeCommits.get(i)[0].toString();
|
public List<Object[]> entityCommits() {
|
||||||
}
|
|
||||||
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);
|
|
||||||
List<Object[]> entityCommits = commitRepository.getCommitEntityStatistic().stream()
|
List<Object[]> entityCommits = commitRepository.getCommitEntityStatistic().stream()
|
||||||
.map(stat -> new Object[]{stat.getEntity(), stat.getCountCommit()})
|
.map(stat -> new Object[]{stat.getEntity(), stat.getCountCommit()})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@ -59,17 +77,24 @@ public class StatisticController {
|
|||||||
? "Нет данных"
|
? "Нет данных"
|
||||||
: "Нет сущностей");
|
: "Нет сущностей");
|
||||||
}
|
}
|
||||||
model.addAttribute("commitEntityData", entityCommits);
|
return entityCommits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Object[]> timeEntityCommits() {
|
||||||
List<Object[]> timeEntityCommits = commitRepository.getCommitTimeEntityStatistic().stream()
|
List<Object[]> timeEntityCommits = commitRepository.getCommitTimeEntityStatistic().stream()
|
||||||
.map(stat -> new Object[]{stat.getDate(), stat.getCountCommit()})
|
.map(stat -> new Object[]{stat.getDate(), stat.getCountCommit()})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
return timeEntityCommits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Object[]> allTimeEntityCommits() {
|
||||||
List<Object[]> allTimeEntityCommits = commitRepository.getCommitTimeStatistic().stream()
|
List<Object[]> allTimeEntityCommits = commitRepository.getCommitTimeStatistic().stream()
|
||||||
.map(stat -> new Object[]{stat.getDate(), stat.getCountCommit()})
|
.map(stat -> new Object[]{stat.getDate(), stat.getCountCommit()})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (int i = 0; i < allTimeEntityCommits.size(); i++) {
|
for (int i = 0; i < allTimeEntityCommits.size(); i++) {
|
||||||
if ((j < timeEntityCommits.size()) && (allTimeEntityCommits.get(i)[0].equals(timeEntityCommits.get(j)[0]))) {
|
if ((j < timeEntityCommits().size()) && (allTimeEntityCommits.get(i)[0].equals(timeEntityCommits().get(j)[0]))) {
|
||||||
allTimeEntityCommits.get(i)[1] = timeEntityCommits.get(j)[1];
|
allTimeEntityCommits.get(i)[1] = timeEntityCommits().get(j)[1];
|
||||||
j++;
|
j++;
|
||||||
} else {
|
} else {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
@ -77,7 +102,6 @@ public class StatisticController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
model.addAttribute("commitTimeEntityData", allTimeEntityCommits);
|
return allTimeEntityCommits;
|
||||||
return STATISTIC;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,44 +79,6 @@
|
|||||||
$('#container').highcharts(json);
|
$('#container').highcharts(json);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script th:inline="javascript">
|
|
||||||
$(document).ready(function () {
|
|
||||||
var chart = {
|
|
||||||
plotBackgroundColor: null,
|
|
||||||
plotBorderWidth: null,
|
|
||||||
plotShadow: false
|
|
||||||
};
|
|
||||||
var title = {
|
|
||||||
text: '% коммитов авторов'
|
|
||||||
};
|
|
||||||
var tooltip = {
|
|
||||||
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
|
|
||||||
};
|
|
||||||
var plotOptions = {
|
|
||||||
pie: {
|
|
||||||
allowPointSelect: true,
|
|
||||||
cursor: 'pointer',
|
|
||||||
dataLabels: {
|
|
||||||
enabled: false
|
|
||||||
},
|
|
||||||
showInLegend: true
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var series = [{
|
|
||||||
type: 'pie',
|
|
||||||
name: 'Browser share',
|
|
||||||
data: [[${commitAuthorData}]]
|
|
||||||
}];
|
|
||||||
|
|
||||||
var json = {};
|
|
||||||
json.chart = chart;
|
|
||||||
json.title = title;
|
|
||||||
json.tooltip = tooltip;
|
|
||||||
json.series = series;
|
|
||||||
json.plotOptions = plotOptions;
|
|
||||||
$('#containerPie').highcharts(json);
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<script th:inline="javascript">
|
<script th:inline="javascript">
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
var chart = {
|
var chart = {
|
||||||
@ -175,14 +137,14 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script th:inline="javascript">
|
<script th:inline="javascript">
|
||||||
$(document).ready(function () {
|
function createPie(data, title) {
|
||||||
var chart = {
|
var chart = {
|
||||||
plotBackgroundColor: null,
|
plotBackgroundColor: null,
|
||||||
plotBorderWidth: null,
|
plotBorderWidth: null,
|
||||||
plotShadow: false
|
plotShadow: false
|
||||||
};
|
};
|
||||||
var title = {
|
var title = {
|
||||||
text: '% коммитов содержащих сущности'
|
text: title
|
||||||
};
|
};
|
||||||
var tooltip = {
|
var tooltip = {
|
||||||
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
|
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
|
||||||
@ -200,7 +162,7 @@
|
|||||||
var series = [{
|
var series = [{
|
||||||
type: 'pie',
|
type: 'pie',
|
||||||
name: 'Browser share',
|
name: 'Browser share',
|
||||||
data: [[${commitEntityData}]]
|
data: data
|
||||||
}];
|
}];
|
||||||
|
|
||||||
var json = {};
|
var json = {};
|
||||||
@ -209,7 +171,11 @@
|
|||||||
json.tooltip = tooltip;
|
json.tooltip = tooltip;
|
||||||
json.series = series;
|
json.series = series;
|
||||||
json.plotOptions = plotOptions;
|
json.plotOptions = plotOptions;
|
||||||
$('#containerEntityPie').highcharts(json);
|
return json;
|
||||||
|
};
|
||||||
|
$(document).ready(function () {
|
||||||
|
$('#containerPie').highcharts(createPie([[${commitAuthorData}]], '% коммитов авторов'));
|
||||||
|
$('#containerEntityPie').highcharts(createPie([[${commitEntityData}]], '% коммитов содержащих сущности'));
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
Loading…
Reference in New Issue
Block a user