#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 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) {

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

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

Loading…
Cancel
Save