From 2cb0ad15ba3768a69104e8327a928537a5bcd954 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Wed, 14 Apr 2021 13:24:59 +0400 Subject: [PATCH 1/2] #22 - Add new statistic pie --- .../controller/StatisticController.java | 4 ++ .../repository/CommitRepository.java | 4 ++ src/main/resources/templates/statistic.html | 39 +++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/src/main/java/ru/ulstu/extractor/controller/StatisticController.java b/src/main/java/ru/ulstu/extractor/controller/StatisticController.java index 13595ee..7952aba 100644 --- a/src/main/java/ru/ulstu/extractor/controller/StatisticController.java +++ b/src/main/java/ru/ulstu/extractor/controller/StatisticController.java @@ -47,6 +47,10 @@ public class StatisticController { url[i] = urlCommits.get(i)[0].toString().substring(urlCommits.get(i)[0].toString().lastIndexOf("/") + 1); } model.addAttribute("urls", url); + List entityCommits = commitRepository.getCommitEntityStatistic().stream() + .map(stat -> new Object[]{stat.getEntity(), stat.getCountCommit()}) + .collect(Collectors.toList()); + model.addAttribute("commitEntityData", entityCommits); return STATISTIC; } } diff --git a/src/main/java/ru/ulstu/extractor/repository/CommitRepository.java b/src/main/java/ru/ulstu/extractor/repository/CommitRepository.java index 9435847..9b92756 100644 --- a/src/main/java/ru/ulstu/extractor/repository/CommitRepository.java +++ b/src/main/java/ru/ulstu/extractor/repository/CommitRepository.java @@ -12,6 +12,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import ru.ulstu.extractor.model.Commit; import ru.ulstu.extractor.model.CommitAuthorStatistic; +import ru.ulstu.extractor.model.CommitEntityStatistic; import ru.ulstu.extractor.model.CommitTimeStatistic; import ru.ulstu.extractor.model.CommitUrlStatistic; import ru.ulstu.extractor.model.Repository; @@ -31,4 +32,7 @@ public interface CommitRepository extends JpaRepository { @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 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 getCommitEntityStatistic(); + } diff --git a/src/main/resources/templates/statistic.html b/src/main/resources/templates/statistic.html index fd2107b..2ed8f82 100644 --- a/src/main/resources/templates/statistic.html +++ b/src/main/resources/templates/statistic.html @@ -174,10 +174,49 @@ }); +
+
From 8b9822de19cfdec1f07606f86c4172a88bfdb0b5 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Wed, 14 Apr 2021 16:56:47 +0400 Subject: [PATCH 2/2] #22 - Change statistic pie --- .../extractor/controller/StatisticController.java | 11 +++++++++++ .../ulstu/extractor/repository/CommitRepository.java | 3 +++ src/main/resources/templates/statistic.html | 10 +++++----- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/ru/ulstu/extractor/controller/StatisticController.java b/src/main/java/ru/ulstu/extractor/controller/StatisticController.java index 7952aba..eaa2340 100644 --- a/src/main/java/ru/ulstu/extractor/controller/StatisticController.java +++ b/src/main/java/ru/ulstu/extractor/controller/StatisticController.java @@ -50,7 +50,18 @@ public class StatisticController { List 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 timeEntityCommits = commitRepository.getCommitTimeEntityStatistic().stream() + .map(stat -> new Object[]{stat.getDate(), stat.getCountCommit()}) + .collect(Collectors.toList()); + model.addAttribute("commitTimeEntityData", timeEntityCommits); return STATISTIC; } } diff --git a/src/main/java/ru/ulstu/extractor/repository/CommitRepository.java b/src/main/java/ru/ulstu/extractor/repository/CommitRepository.java index 9b92756..f7fe48a 100644 --- a/src/main/java/ru/ulstu/extractor/repository/CommitRepository.java +++ b/src/main/java/ru/ulstu/extractor/repository/CommitRepository.java @@ -35,4 +35,7 @@ public interface CommitRepository extends JpaRepository { @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 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 getCommitTimeEntityStatistic(); + } diff --git a/src/main/resources/templates/statistic.html b/src/main/resources/templates/statistic.html index 2ed8f82..a1f9c9a 100644 --- a/src/main/resources/templates/statistic.html +++ b/src/main/resources/templates/statistic.html @@ -15,10 +15,6 @@