#18 -- Fix selection unique commits

This commit is contained in:
Anton Romanov 2021-04-08 11:11:21 +04:00
parent 818bf6a349
commit a76b5cd05f

View File

@ -1,3 +1,8 @@
/*
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
*/
package ru.ulstu.extractor.repository;
import org.springframework.data.domain.Page;
@ -17,13 +22,13 @@ public interface CommitRepository extends JpaRepository<Commit, Integer> {
@Query("SELECT c FROM Commit c, Repository r, Branch b WHERE c.branch = b AND r = b.repository AND r = :repository AND b.name = :branchName")
Page<Commit> findByRepositoryAndBranch(Pageable pageable, @Param("repository") Repository repository, @Param("branchName") String branchName);
@Query("SELECT new ru.ulstu.extractor.model.CommitAuthorStatistic(c.author.name, COUNT(c)) FROM Commit c GROUP by c.author.name")
@Query("SELECT new ru.ulstu.extractor.model.CommitAuthorStatistic(c.author.name, COUNT(DISTINCT c.hash)) FROM Commit c GROUP by c.author.name")
List<CommitAuthorStatistic> getCommitAuthorStatistic();
@Query("SELECT new ru.ulstu.extractor.model.CommitUrlStatistic(c.branch.repository.url, COUNT(c)) 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();
@Query("SELECT new ru.ulstu.extractor.model.CommitTimeStatistic(cast(c.date as date), COUNT(c)) 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();
}