#22 - Add new statistic pie

This commit is contained in:
Anton Romanov 2021-04-14 13:24:59 +04:00
parent e61e13e342
commit 2cb0ad15ba
3 changed files with 47 additions and 0 deletions

View File

@ -47,6 +47,10 @@ 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());
model.addAttribute("commitEntityData", entityCommits);
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,7 @@ 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();
} }

View File

@ -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>