Resolve "BUG:не отображается динамика коммитов" #56

Merged
BarminaA merged 1 commits from 28-bug into master 2021-05-12 11:08:13 +04:00
2 changed files with 11 additions and 10 deletions
Showing only changes of commit 1cd0f3fe31 - Show all commits

View File

@ -1,18 +1,19 @@
package ru.ulstu.extractor.model; package ru.ulstu.extractor.model;
import java.util.Date;
public class CommitTimeStatistic { public class CommitTimeStatistic {
private Date date; private final static String DATE_TEMPLATE = "%s.%s";
private Long countCommit; private final int month;
private final int year;
private final Long countCommit;
public CommitTimeStatistic(Date date, Long countCommit) { public CommitTimeStatistic(int month, int year, Long countCommit) {
this.date = date; this.month = month;
this.year = year;
this.countCommit = countCommit; this.countCommit = countCommit;
} }
public Date getDate() { public String getDate() {
return date; return String.format(DATE_TEMPLATE, month, year);
} }
public Long getCountCommit() { public Long getCountCommit() {

View File

@ -29,13 +29,13 @@ public interface CommitRepository extends JpaRepository<Commit, Integer> {
@Query("SELECT new ru.ulstu.extractor.model.CommitUrlStatistic(c.branch.repository.url, COUNT(DISTINCT c.hash)) FROM Commit c GROUP by c.branch.repository.url") @Query("SELECT new ru.ulstu.extractor.model.CommitUrlStatistic(c.branch.repository.url, COUNT(DISTINCT c.hash)) FROM Commit c GROUP by c.branch.repository.url")
List<CommitUrlStatistic> getCommitUrlStatistic(); List<CommitUrlStatistic> getCommitUrlStatistic();
@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(extract(month FROM c.date) as month, extract(year FROM c.date) as year, COUNT(DISTINCT c.hash)) FROM Commit c GROUP by extract(month from c.date), extract(year from c.date) ORDER by extract(year from c.date), extract(month from c.date)")
List<CommitTimeStatistic> getCommitTimeStatistic(); List<CommitTimeStatistic> getCommitTimeStatistic();
@Query("SELECT new ru.ulstu.extractor.model.CommitEntityStatistic(f.containsEntity, COUNT(DISTINCT c.hash)) FROM Commit c JOIN c.fileChanges f GROUP by f.containsEntity") @Query("SELECT new ru.ulstu.extractor.model.CommitEntityStatistic(f.containsEntity, COUNT(DISTINCT c.hash)) FROM Commit c JOIN c.fileChanges f GROUP by f.containsEntity")
List<CommitEntityStatistic> getCommitEntityStatistic(); List<CommitEntityStatistic> getCommitEntityStatistic();
@Query("SELECT new ru.ulstu.extractor.model.CommitTimeStatistic(cast(c.date as date), COUNT(DISTINCT c.hash)) FROM Commit c JOIN c.fileChanges f WHERE f.containsEntity = true GROUP by cast(c.date as date) ORDER by cast(c.date as date)") @Query("SELECT new ru.ulstu.extractor.model.CommitTimeStatistic(EXTRACT(MONTH FROM c.date), EXTRACT(YEAR FROM c.date), COUNT(DISTINCT c.hash)) FROM Commit c JOIN c.fileChanges f WHERE f.containsEntity = true GROUP by extract(month from c.date), extract(year from c.date) ORDER by extract(year from c.date), extract(month from c.date)")
List<CommitTimeStatistic> getCommitTimeEntityStatistic(); List<CommitTimeStatistic> getCommitTimeEntityStatistic();
void deleteByBranchIsNull(); void deleteByBranchIsNull();