Resolve "Добавить диаграмму для сущностей" #49

Merged
BarminaA merged 1 commits from 22-entity-diagram into master 2021-04-14 16:59:18 +04:00
3 changed files with 19 additions and 5 deletions
Showing only changes of commit 8b9822de19 - Show all commits

View File

@ -50,7 +50,18 @@ public class StatisticController {
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])
? "Есть сущности"
: (entityCommits.get(i)[0] == null
? "Нет данных"
: "Нет сущностей");
}
model.addAttribute("commitEntityData", entityCommits);
List<Object[]> timeEntityCommits = commitRepository.getCommitTimeEntityStatistic().stream()
.map(stat -> new Object[]{stat.getDate(), stat.getCountCommit()})
.collect(Collectors.toList());
model.addAttribute("commitTimeEntityData", timeEntityCommits);
return STATISTIC;
}
}

View File

@ -35,4 +35,7 @@ public interface CommitRepository extends JpaRepository<Commit, Integer> {
@Query("SELECT new ru.ulstu.extractor.model.CommitEntityStatistic(f.containsEntity, COUNT(DISTINCT c.hash)) FROM FileChange f, Commit c WHERE f MEMBER OF c.fileChanges GROUP by f.containsEntity")
List<CommitEntityStatistic> getCommitEntityStatistic();
@Query("SELECT new ru.ulstu.extractor.model.CommitTimeStatistic(cast(c.date as date), COUNT(DISTINCT c.hash)) FROM Commit c, FileChange f WHERE f MEMBER OF c.fileChanges AND f.containsEntity = true GROUP by cast(c.date as date) ORDER by cast(c.date as date)")
List<CommitTimeStatistic> getCommitTimeEntityStatistic();
}

View File

@ -15,10 +15,6 @@
<script src="/webjars/highcharts/7.0.0/highcharts.js"></script>
<script th:inline="javascript">
$(document).ready(function () {
var chart = {
type: 'scatter',
zoomType: 'xy'
};
var title = {
text: 'Количество коммитов во времени'
};
@ -66,11 +62,15 @@
name: 'Коммиты',
color: 'rgba(119,152,191,0.5)',
data: [[${commitTimeData}]]
},
{
name: 'Сущности',
color: 'rgba(255,0,0,0.5)',
data: [[${commitTimeEntityData}]]
}
];
var json = {};
json.chart = chart;
json.title = title;
json.xAxis = xAxis;
json.yAxis = yAxis;