#21 -- Add entity filter

merge-requests/19/head
Anton Romanov 3 years ago
parent b25a1dbab9
commit 6c6e8fdc3b

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

@ -48,6 +48,11 @@ public class StatisticController {
}
model.addAttribute("urls", url);
// List<Object[]> entityCommits = commitRepository.getCommitEntityStatistic().stream()
// .map(stat -> new Object[]{stat.getEntity(), stat.getCountCommit()})
// .collect(Collectors.toList());
// model.addAttribute("commitTimeData", timeCommits);
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();
@ -31,4 +31,6 @@ public interface CommitRepository extends JpaRepository<Commit, Integer> {
@Query("SELECT new ru.ulstu.extractor.model.CommitTimeStatistic(cast(c.date as date), COUNT(DISTINCT c.hash)) FROM Commit c GROUP by cast(c.date as date) ORDER by cast(c.date as date)")
List<CommitTimeStatistic> getCommitTimeStatistic();
// @Query("SELECT new ru.ulstu.extractor.model.CommitEntityStatistic(f.containsEntity, COUNT(DISTINCT f.commit.hash)) FROM FileChange f GROUP by f.containsEntity")
// List<CommitEntityStatistic> getCommitEntityStatistic();
}

@ -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…
Cancel
Save