Merge branch '22-entity-diagram' into 'master'

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

Closes #22

See merge request romanov73/git-extractor!20
This commit is contained in:
Anton Romanov 2021-04-14 12:59:17 +00:00
commit de2713e9d8
3 changed files with 66 additions and 5 deletions

View File

@ -47,6 +47,21 @@ public class StatisticController {
url[i] = urlCommits.get(i)[0].toString().substring(urlCommits.get(i)[0].toString().lastIndexOf("/") + 1); url[i] = urlCommits.get(i)[0].toString().substring(urlCommits.get(i)[0].toString().lastIndexOf("/") + 1);
} }
model.addAttribute("urls", url); 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])
? "Есть сущности"
: (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; return STATISTIC;
} }
} }

View File

@ -12,6 +12,7 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import ru.ulstu.extractor.model.Commit; import ru.ulstu.extractor.model.Commit;
import ru.ulstu.extractor.model.CommitAuthorStatistic; import ru.ulstu.extractor.model.CommitAuthorStatistic;
import ru.ulstu.extractor.model.CommitEntityStatistic;
import ru.ulstu.extractor.model.CommitTimeStatistic; import ru.ulstu.extractor.model.CommitTimeStatistic;
import ru.ulstu.extractor.model.CommitUrlStatistic; import ru.ulstu.extractor.model.CommitUrlStatistic;
import ru.ulstu.extractor.model.Repository; import ru.ulstu.extractor.model.Repository;
@ -31,4 +32,10 @@ public interface CommitRepository extends JpaRepository<Commit, Integer> {
@Query("SELECT new ru.ulstu.extractor.model.CommitTimeStatistic(cast(c.date as date), COUNT(DISTINCT c.hash)) FROM Commit c GROUP by cast(c.date as date) ORDER by cast(c.date as date)") @Query("SELECT new ru.ulstu.extractor.model.CommitTimeStatistic(cast(c.date as date), COUNT(DISTINCT c.hash)) FROM Commit c GROUP by cast(c.date as date) ORDER by cast(c.date as date)")
List<CommitTimeStatistic> getCommitTimeStatistic(); List<CommitTimeStatistic> getCommitTimeStatistic();
@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 src="/webjars/highcharts/7.0.0/highcharts.js"></script>
<script th:inline="javascript"> <script th:inline="javascript">
$(document).ready(function () { $(document).ready(function () {
var chart = {
type: 'scatter',
zoomType: 'xy'
};
var title = { var title = {
text: 'Количество коммитов во времени' text: 'Количество коммитов во времени'
}; };
@ -66,11 +62,15 @@
name: 'Коммиты', name: 'Коммиты',
color: 'rgba(119,152,191,0.5)', color: 'rgba(119,152,191,0.5)',
data: [[${commitTimeData}]] data: [[${commitTimeData}]]
},
{
name: 'Сущности',
color: 'rgba(255,0,0,0.5)',
data: [[${commitTimeEntityData}]]
} }
]; ];
var json = {}; var json = {};
json.chart = chart;
json.title = title; json.title = title;
json.xAxis = xAxis; json.xAxis = xAxis;
json.yAxis = yAxis; json.yAxis = yAxis;
@ -174,10 +174,49 @@
}); });
</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: [[${commitEntityData}]]
}];
var json = {};
json.chart = chart;
json.title = title;
json.tooltip = tooltip;
json.series = series;
json.plotOptions = plotOptions;
$('#containerEntityPie').highcharts(json);
});
</script>
<div class="row"> <div class="row">
<div id="container" style="width: 550px; height: 400px; margin: 0 auto"></div> <div id="container" style="width: 550px; height: 400px; margin: 0 auto"></div>
<div id="containerPie" style="width: 550px; height: 400px; margin: 0 auto"></div> <div id="containerPie" style="width: 550px; height: 400px; margin: 0 auto"></div>
<div id="containerColumn" style="width: 550px; height: 400px; margin: 0 auto"></div> <div id="containerColumn" style="width: 550px; height: 400px; margin: 0 auto"></div>
<div id="containerEntityPie" style="width: 550px; height: 400px; margin: 0 auto"></div>
</div> </div>
</div> </div>
</html> </html>