#19 - Add filter by author
This commit is contained in:
parent
7c59b3630c
commit
3cdc712a2c
@ -29,6 +29,7 @@ public class GitFilteringController {
|
|||||||
private final static int DEFAULT_PAGE_SIZE = 20;
|
private final static int DEFAULT_PAGE_SIZE = 20;
|
||||||
private final FilteringService filteringService;
|
private final FilteringService filteringService;
|
||||||
|
|
||||||
|
|
||||||
public GitFilteringController(FilteringService filteringService) {
|
public GitFilteringController(FilteringService filteringService) {
|
||||||
this.filteringService = filteringService;
|
this.filteringService = filteringService;
|
||||||
}
|
}
|
||||||
@ -43,9 +44,11 @@ public class GitFilteringController {
|
|||||||
@RequestParam String branchName) {
|
@RequestParam String branchName) {
|
||||||
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";
|
||||||
|
|
||||||
Page<Commit> commitsPage = filteringService.getCommits(repositoryUrl,
|
Page<Commit> commitsPage = filteringService.getCommits(repositoryUrl,
|
||||||
branchName,
|
branchName,
|
||||||
|
author,
|
||||||
new OffsetablePageRequest(currentPage - 1, pageSize));
|
new OffsetablePageRequest(currentPage - 1, pageSize));
|
||||||
int totalPages = commitsPage.getTotalPages();
|
int totalPages = commitsPage.getTotalPages();
|
||||||
if (totalPages > 0) {
|
if (totalPages > 0) {
|
||||||
@ -61,4 +64,24 @@ public class GitFilteringController {
|
|||||||
model.addAttribute("authors", filteringService.getRepositoryAuthors(repositoryUrl, branchName));
|
model.addAttribute("authors", filteringService.getRepositoryAuthors(repositoryUrl, branchName));
|
||||||
return FILTER_COMMITS;
|
return FILTER_COMMITS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @RequestMapping(value = FILTER_COMMITS, method = RequestMethod.POST)
|
||||||
|
// public ModelAndView listFilterCommits(
|
||||||
|
// Model model,
|
||||||
|
// @ModelAttribute FilterForm filterForm) {
|
||||||
|
// Page<Commit> commitsPage = filteringService.getCommits(filterForm.getUrl(),
|
||||||
|
// filterForm.getBranch(),
|
||||||
|
// new OffsetablePageRequest(0, DEFAULT_PAGE_SIZE));
|
||||||
|
// int totalPages = commitsPage.getTotalPages();
|
||||||
|
// if (totalPages > 0) {
|
||||||
|
// List<Integer> pageNumbers = IntStream.rangeClosed(1, totalPages)
|
||||||
|
// .boxed()
|
||||||
|
// .collect(Collectors.toList());
|
||||||
|
// model.addAttribute("pageNumbers", pageNumbers);
|
||||||
|
// }
|
||||||
|
// filterForm.setCommitsPage(commitsPage);
|
||||||
|
// model.addAttribute("filterForm", filterForm);
|
||||||
|
// model.addAttribute("authors", filteringService.getRepositoryAuthors(filterForm.getUrl(), filterForm.getBranch()));
|
||||||
|
// return new ModelAndView()FILTER_COMMITS + "?repositoryUrl="+filterForm.getUrl() + "&branchName=" +filterForm.getBranch() ;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
@ -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 WHERE c.branch = b AND r = b.repository AND r = :repository AND b.name = :branchName")
|
@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);
|
Page<Commit> findByRepositoryAndBranch(Pageable pageable, @Param("repository") Repository repository, @Param("branchName") String branchName, @Param("author") String author);
|
||||||
|
|
||||||
@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();
|
||||||
|
@ -40,11 +40,13 @@ 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,
|
||||||
Pageable pageable) {
|
Pageable pageable) {
|
||||||
return commitRepository.findByRepositoryAndBranch(
|
return commitRepository.findByRepositoryAndBranch(
|
||||||
pageable,
|
pageable,
|
||||||
repositoryRepository.findByUrl(repositoryUrl),
|
repositoryRepository.findByUrl(repositoryUrl),
|
||||||
branchName
|
branchName,
|
||||||
|
author
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +74,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="hidden" th:field="*{url}">
|
<input type="hidden" th:field="*{url}">
|
||||||
|
<input type="hidden" th:field="*{branch}">
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead class="thead-dark">
|
<thead class="thead-dark">
|
||||||
<tr>
|
<tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user