#19 - Add new filter

This commit is contained in:
Anton Romanov 2021-04-09 14:26:28 +04:00
parent 3cdc712a2c
commit 61163d2f8f
3 changed files with 7 additions and 3 deletions

View File

@ -45,10 +45,12 @@ public class GitFilteringController {
int currentPage = page.orElse(1);
int pageSize = size.orElse(DEFAULT_PAGE_SIZE);
String author = "Anton Romanov";
String filter = "fix";
Page<Commit> commitsPage = filteringService.getCommits(repositoryUrl,
branchName,
author,
filter,
new OffsetablePageRequest(currentPage - 1, pageSize));
int totalPages = commitsPage.getTotalPages();
if (totalPages > 0) {

View File

@ -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 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 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();

View File

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