#19 - Add new filter

merge-requests/16/head
Anton Romanov 3 years ago
parent 3cdc712a2c
commit 61163d2f8f

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

@ -19,8 +19,8 @@ import ru.ulstu.extractor.model.Repository;
import java.util.List; import java.util.List;
public interface CommitRepository extends JpaRepository<Commit, Integer> { 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") @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); 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") @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(); List<CommitAuthorStatistic> getCommitAuthorStatistic();

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

Loading…
Cancel
Save