Merge branch '21--filter-by-entity' into 'master'
Resolve "Фильтр по сущности" Closes #21 See merge request romanov73/git-extractor!19
This commit is contained in:
commit
1cd785ee41
@ -40,7 +40,8 @@ public class GitFilteringController {
|
||||
@RequestParam Optional<String> repositoryUrl,
|
||||
@RequestParam Optional<String> branchName,
|
||||
@RequestParam Optional<String> author,
|
||||
@RequestParam Optional<String> filter) {
|
||||
@RequestParam Optional<String> filter,
|
||||
@RequestParam Optional<Boolean> entity) {
|
||||
int currentPage = page.orElse(1);
|
||||
int pageSize = size.orElse(DEFAULT_PAGE_SIZE);
|
||||
|
||||
@ -51,6 +52,7 @@ public class GitFilteringController {
|
||||
notEmptyBranchName,
|
||||
author.orElse(null),
|
||||
filter.orElse(null),
|
||||
entity.orElse(null),
|
||||
new OffsetablePageRequest(currentPage - 1, pageSize));
|
||||
int totalPages = commitsPage.getTotalPages();
|
||||
if (totalPages > 0) {
|
||||
|
@ -47,7 +47,6 @@ public class StatisticController {
|
||||
url[i] = urlCommits.get(i)[0].toString().substring(urlCommits.get(i)[0].toString().lastIndexOf("/") + 1);
|
||||
}
|
||||
model.addAttribute("urls", url);
|
||||
|
||||
return STATISTIC;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package ru.ulstu.extractor.model;
|
||||
|
||||
public class CommitEntityStatistic {
|
||||
private Boolean entity;
|
||||
private Long countCommit;
|
||||
|
||||
public CommitEntityStatistic(Boolean entity, Long countCommit) {
|
||||
this.entity = entity;
|
||||
this.countCommit = countCommit;
|
||||
}
|
||||
|
||||
public Boolean getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public Long getCountCommit() {
|
||||
return countCommit;
|
||||
}
|
||||
|
||||
}
|
@ -13,6 +13,7 @@ public class FilterForm {
|
||||
private String repositoryUrl;
|
||||
private String branchName;
|
||||
private String author;
|
||||
private boolean entity;
|
||||
private Page<Commit> commitsPage;
|
||||
|
||||
public FilterForm() {
|
||||
@ -62,6 +63,14 @@ public class FilterForm {
|
||||
this.branchName = branchName;
|
||||
}
|
||||
|
||||
public boolean getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public void setEntity(boolean entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FilterForm{" +
|
||||
@ -70,6 +79,7 @@ public class FilterForm {
|
||||
", branchName='" + branchName + '\'' +
|
||||
", author='" + author + '\'' +
|
||||
", commitsPage=" + commitsPage +
|
||||
", entity='" + entity +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -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) AND (:filter IS NULL OR :filter = '' OR lower(c.message) LIKE lower(concat('%', :filter,'%')))")
|
||||
Page<Commit> findByRepositoryAndBranch(Pageable pageable, @Param("repository") Repository repository, @Param("branchName") String branchName, @Param("author") String author, @Param("filter") String filter);
|
||||
@Query("SELECT c FROM Commit c, Repository r, Branch b, Author a, FileChange f WHERE c.branch = b AND r = b.repository AND a = c.author AND f MEMBER OF c.fileChanges AND r = :repository AND b.name = :branchName AND (:author IS NULL OR :author = '' OR a.name = :author) AND (:filter IS NULL OR :filter = '' OR lower(c.message) LIKE lower(concat('%', :filter,'%'))) AND (:entity IS NULL OR f.containsEntity = :entity)")
|
||||
Page<Commit> findByRepositoryAndBranch(Pageable pageable, @Param("repository") Repository repository, @Param("branchName") String branchName, @Param("author") String author, @Param("filter") String filter, @Param("entity") Boolean entity);
|
||||
|
||||
@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();
|
||||
|
@ -42,13 +42,15 @@ public class FilteringService {
|
||||
@NotNull String branchName,
|
||||
String author,
|
||||
String filter,
|
||||
Boolean entity,
|
||||
Pageable pageable) {
|
||||
return commitRepository.findByRepositoryAndBranch(
|
||||
pageable,
|
||||
repositoryRepository.findByUrl(repositoryUrl),
|
||||
branchName,
|
||||
author,
|
||||
filter
|
||||
filter,
|
||||
entity
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,12 @@
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<input type="text" class="form-control" size="40" th:field="*{filter}">
|
||||
</div>
|
||||
<div class="col-md-2 col-sm-12">
|
||||
Содержит сущность:
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<input type="checkbox" class="form-check-input" th:field="*{entity}">
|
||||
</div>
|
||||
<div class="col-md-4 col-sm-12">
|
||||
<input type="submit" class="btn btn-outline-success w-100" value="Применить фильтр"/>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user