Merge remote-tracking branch 'origin/19-filtering-by-author' into 19-filtering-by-author

# Conflicts:
#	src/main/java/ru/ulstu/extractor/controller/GitFilteringController.java
#	src/main/java/ru/ulstu/extractor/repository/CommitRepository.java
#	src/main/java/ru/ulstu/extractor/service/FilteringService.java
merge-requests/16/head
Anton Romanov 3 years ago
commit d69c4ea5f5

@ -19,8 +19,8 @@ import ru.ulstu.extractor.model.Repository;
import java.util.List;
public interface CommitRepository extends JpaRepository<Commit, Integer> {
@Query("SELECT c FROM Commit c, Repository r, Branch b, Author a WHERE c.branch = b AND r = b.repository AND a = c.author AND r = :repository AND b.name = :branchName AND (:author IS NULL OR :author = '' OR a.name = :author)")
Page<Commit> findByRepositoryAndBranch(Pageable pageable, @Param("repository") Repository repository, @Param("branchName") String branchName, @Param("author") String author);
@Query("SELECT c FROM Commit c, Repository r, Branch b, Author a WHERE c.branch = b AND r = b.repository AND a = c.author AND r = :repository AND b.name = :branchName AND (:author IS NULL OR :author = '' OR a.name = :author) AND c.message LIKE %:filter%")
Page<Commit> findByRepositoryAndBranch(Pageable pageable, @Param("repository") Repository repository, @Param("branchName") String branchName, @Param("author") String author, @Param("filter") String filter);
@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();

@ -41,12 +41,14 @@ public class FilteringService {
public Page<Commit> getCommits(@NotNull String repositoryUrl,
@NotNull String branchName,
String author,
String filter,
Pageable pageable) {
return commitRepository.findByRepositoryAndBranch(
pageable,
repositoryRepository.findByUrl(repositoryUrl),
branchName,
author
author,
filter
);
}
}

Loading…
Cancel
Save