Merge remote-tracking branch 'origin/master' into master
This commit is contained in:
commit
ead70696ec
@ -40,7 +40,8 @@ public class GitFilteringController {
|
|||||||
@RequestParam Optional<String> repositoryUrl,
|
@RequestParam Optional<String> repositoryUrl,
|
||||||
@RequestParam Optional<String> branchName,
|
@RequestParam Optional<String> branchName,
|
||||||
@RequestParam Optional<String> author,
|
@RequestParam Optional<String> author,
|
||||||
@RequestParam Optional<String> filter) {
|
@RequestParam Optional<String> filter,
|
||||||
|
@RequestParam Optional<Boolean> entity) {
|
||||||
int currentPage = page.orElse(1);
|
int currentPage = page.orElse(1);
|
||||||
int pageSize = size.orElse(DEFAULT_PAGE_SIZE);
|
int pageSize = size.orElse(DEFAULT_PAGE_SIZE);
|
||||||
|
|
||||||
@ -51,6 +52,7 @@ public class GitFilteringController {
|
|||||||
notEmptyBranchName,
|
notEmptyBranchName,
|
||||||
author.orElse(null),
|
author.orElse(null),
|
||||||
filter.orElse(null),
|
filter.orElse(null),
|
||||||
|
entity.orElse(null),
|
||||||
new OffsetablePageRequest(currentPage - 1, pageSize));
|
new OffsetablePageRequest(currentPage - 1, pageSize));
|
||||||
int totalPages = commitsPage.getTotalPages();
|
int totalPages = commitsPage.getTotalPages();
|
||||||
if (totalPages > 0) {
|
if (totalPages > 0) {
|
||||||
@ -65,6 +67,7 @@ public class GitFilteringController {
|
|||||||
filterForm.setRepositoryUrl(notEmptyRepositoryUrl);
|
filterForm.setRepositoryUrl(notEmptyRepositoryUrl);
|
||||||
filterForm.setAuthor(author.orElse(null));
|
filterForm.setAuthor(author.orElse(null));
|
||||||
filterForm.setFilter(filter.orElse(null));
|
filterForm.setFilter(filter.orElse(null));
|
||||||
|
filterForm.setEntity(entity.orElse(false));
|
||||||
model.addAttribute("filterForm", filterForm);
|
model.addAttribute("filterForm", filterForm);
|
||||||
model.addAttribute("authors", filteringService.getRepositoryAuthors(
|
model.addAttribute("authors", filteringService.getRepositoryAuthors(
|
||||||
notEmptyRepositoryUrl,
|
notEmptyRepositoryUrl,
|
||||||
|
@ -47,7 +47,6 @@ public class StatisticController {
|
|||||||
url[i] = urlCommits.get(i)[0].toString().substring(urlCommits.get(i)[0].toString().lastIndexOf("/") + 1);
|
url[i] = urlCommits.get(i)[0].toString().substring(urlCommits.get(i)[0].toString().lastIndexOf("/") + 1);
|
||||||
}
|
}
|
||||||
model.addAttribute("urls", url);
|
model.addAttribute("urls", url);
|
||||||
|
|
||||||
return STATISTIC;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,55 +0,0 @@
|
|||||||
package ru.ulstu.extractor.model;
|
|
||||||
|
|
||||||
import org.eclipse.jgit.diff.DiffEntry;
|
|
||||||
import org.eclipse.jgit.diff.DiffFormatter;
|
|
||||||
import org.eclipse.jgit.revwalk.RevCommit;
|
|
||||||
import org.eclipse.jgit.revwalk.RevWalk;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class NewClass {
|
|
||||||
|
|
||||||
private final RevWalk revWalk;
|
|
||||||
private final DiffFormatter diffFormatter;
|
|
||||||
|
|
||||||
private NewClass(RevWalk revWalk, DiffFormatter diffFormatter) {
|
|
||||||
this.revWalk = revWalk;
|
|
||||||
this.diffFormatter = diffFormatter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getModified(final RevCommit commit) throws IOException {
|
|
||||||
final RevCommit[] parents = commit.getParents();
|
|
||||||
final Set<String> result = new HashSet<>();
|
|
||||||
if (parents.length == 1) { // merge commit if length > 1
|
|
||||||
final RevCommit parent = revWalk.parseCommit(parents[0].getId());
|
|
||||||
// get diff of this commit to its parent, as list of paths
|
|
||||||
final List<DiffEntry> diffs = getDiffEntries(commit, parent);
|
|
||||||
for (final DiffEntry diff : diffs) {
|
|
||||||
final String changePath = diff.getChangeType().equals(DiffEntry.ChangeType.DELETE) ? diff.getOldPath() : diff.getNewPath();
|
|
||||||
result.add(changePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<DiffEntry> getDiffEntries(final RevCommit commit, final RevCommit parent) {
|
|
||||||
try {
|
|
||||||
return diffFormatter.scan(parent.getTree(), commit.getTree());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Первая основная таблица: коммит, автор, дата
|
|
||||||
// Вторая таблица : коммит, имя файла, добавленные строки, удаленные строки
|
|
||||||
|
|
||||||
// Фильтрация коммитов по автору(только основная таблица)
|
|
||||||
// Фильтрация коммитов по дате
|
|
||||||
// Фильтрация коммитов по именни файла, или добавленные строки.
|
|
||||||
|
|
@ -13,6 +13,7 @@ public class FilterForm {
|
|||||||
private String repositoryUrl;
|
private String repositoryUrl;
|
||||||
private String branchName;
|
private String branchName;
|
||||||
private String author;
|
private String author;
|
||||||
|
private boolean entity;
|
||||||
private Page<Commit> commitsPage;
|
private Page<Commit> commitsPage;
|
||||||
|
|
||||||
public FilterForm() {
|
public FilterForm() {
|
||||||
@ -62,6 +63,14 @@ public class FilterForm {
|
|||||||
this.branchName = branchName;
|
this.branchName = branchName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getEntity() {
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntity(boolean entity) {
|
||||||
|
this.entity = entity;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "FilterForm{" +
|
return "FilterForm{" +
|
||||||
@ -70,6 +79,7 @@ public class FilterForm {
|
|||||||
", branchName='" + branchName + '\'' +
|
", branchName='" + branchName + '\'' +
|
||||||
", author='" + author + '\'' +
|
", author='" + author + '\'' +
|
||||||
", commitsPage=" + commitsPage +
|
", commitsPage=" + commitsPage +
|
||||||
|
", entity='" + entity +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 (:author IS NULL OR :author = '' OR a.name = :author) AND (:filter IS NULL OR :filter = '' OR lower(c.message) LIKE lower(concat('%', :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);
|
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")
|
@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();
|
||||||
|
@ -42,13 +42,15 @@ public class FilteringService {
|
|||||||
@NotNull String branchName,
|
@NotNull String branchName,
|
||||||
String author,
|
String author,
|
||||||
String filter,
|
String filter,
|
||||||
|
Boolean entity,
|
||||||
Pageable pageable) {
|
Pageable pageable) {
|
||||||
return commitRepository.findByRepositoryAndBranch(
|
return commitRepository.findByRepositoryAndBranch(
|
||||||
pageable,
|
pageable,
|
||||||
repositoryRepository.findByUrl(repositoryUrl),
|
repositoryRepository.findByUrl(repositoryUrl),
|
||||||
branchName,
|
branchName,
|
||||||
author,
|
author,
|
||||||
filter
|
filter,
|
||||||
|
entity
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,12 @@
|
|||||||
<div class="col-md-6 col-sm-12">
|
<div class="col-md-6 col-sm-12">
|
||||||
<input type="text" class="form-control" size="40" th:field="*{filter}">
|
<input type="text" class="form-control" size="40" th:field="*{filter}">
|
||||||
</div>
|
</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}" th:checked="*{entity}"/>
|
||||||
|
</div>
|
||||||
<div class="col-md-4 col-sm-12">
|
<div class="col-md-4 col-sm-12">
|
||||||
<input type="submit" class="btn btn-outline-success w-100" value="Применить фильтр"/>
|
<input type="submit" class="btn btn-outline-success w-100" value="Применить фильтр"/>
|
||||||
</div>
|
</div>
|
||||||
@ -111,7 +117,8 @@
|
|||||||
repositoryUrl=${filterForm.repositoryUrl},
|
repositoryUrl=${filterForm.repositoryUrl},
|
||||||
branchName=${filterForm.branchName},
|
branchName=${filterForm.branchName},
|
||||||
author=${filterForm.author},
|
author=${filterForm.author},
|
||||||
filter=${filterForm.filter})}"
|
filter=${filterForm.filter},
|
||||||
|
entity=${filterForm.entity})}"
|
||||||
th:text=${pageNumber}
|
th:text=${pageNumber}
|
||||||
th:class="${pageNumber == filterForm.commitsPage.number} ? active"></a>
|
th:class="${pageNumber == filterForm.commitsPage.number} ? active"></a>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user