WIP: страницы для правил #62

Closed
Ghost wants to merge 132 commits from master into 61-rules-pages
3 changed files with 21 additions and 4 deletions
Showing only changes of commit b711d70eac - Show all commits

View File

@ -56,8 +56,8 @@ public class GitRepositoryService {
private static final String BRANCH_PREFIX = "refs/remotes/origin/"; private static final String BRANCH_PREFIX = "refs/remotes/origin/";
@Value("${extractor.custom-projects-dir}") @Value("${extractor.custom-projects-dir}")
private String customProjectsDir; private String customProjectsDir;
private final ExecutorService executorService = Executors.newFixedThreadPool(4); private final ExecutorService executorService = Executors.newFixedThreadPool(8);
private final ExecutorService executorServiceCommits = Executors.newFixedThreadPool(4); private final ExecutorService executorServiceCommits = Executors.newFixedThreadPool(8);
private final StructuralUnitService structuralUnitService; private final StructuralUnitService structuralUnitService;
private final GitRepositoryRepository gitRepositoryRepository; private final GitRepositoryRepository gitRepositoryRepository;
@ -370,4 +370,8 @@ public class GitRepositoryService {
public Page<GitRepository> findAll(Pageable pageable) { public Page<GitRepository> findAll(Pageable pageable) {
return gitRepositoryRepository.findAll(pageable); return gitRepositoryRepository.findAll(pageable);
} }
public GitRepository findById(Integer id) {
return gitRepositoryRepository.getOne(id);
}
} }

View File

@ -22,4 +22,11 @@ public class GitRepository extends BaseEntity {
public void setUrl(String url) { public void setUrl(String url) {
this.url = url; this.url = url;
} }
public String getName() {
int lastDelimiterIndex = url.lastIndexOf("/");
return (lastDelimiterIndex > 0 && lastDelimiterIndex < url.length())
? url.substring(lastDelimiterIndex + 1)
: url;
}
} }

View File

@ -2,6 +2,7 @@ package ru.ulstu.extractor.ts;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import ru.ulstu.extractor.commit.service.CommitService; import ru.ulstu.extractor.commit.service.CommitService;
import ru.ulstu.extractor.gitrepository.GitRepositoryService;
import ru.ulstu.extractor.model.TimeSeriesValue; import ru.ulstu.extractor.model.TimeSeriesValue;
import ru.ulstu.extractor.service.TimeSeriesService; import ru.ulstu.extractor.service.TimeSeriesService;
@ -14,11 +15,14 @@ import java.util.stream.Collectors;
public class CommitsTS extends AbstractTimeSeriesCreator { public class CommitsTS extends AbstractTimeSeriesCreator {
private final TimeSeriesService timeSeriesService; private final TimeSeriesService timeSeriesService;
private final CommitService commitService; private final CommitService commitService;
private final GitRepositoryService gitRepositoryService;
public CommitsTS(TimeSeriesService timeSeriesService, public CommitsTS(TimeSeriesService timeSeriesService,
CommitService commitService) { CommitService commitService,
GitRepositoryService gitRepositoryService) {
this.timeSeriesService = timeSeriesService; this.timeSeriesService = timeSeriesService;
this.commitService = commitService; this.commitService = commitService;
this.gitRepositoryService = gitRepositoryService;
} }
@Override @Override
@ -30,7 +34,9 @@ public class CommitsTS extends AbstractTimeSeriesCreator {
public Map<String, List<TimeSeriesValue>> getTimeSeriesValues(Integer repositoryId, String branchName) { public Map<String, List<TimeSeriesValue>> getTimeSeriesValues(Integer repositoryId, String branchName) {
//TODO: добавить постраничное чтение //TODO: добавить постраничное чтение
Map<String, List<TimeSeriesValue>> result = new HashMap<>(); Map<String, List<TimeSeriesValue>> result = new HashMap<>();
result.put(String.format("%s %s %s", getTimeSeriesName(), repositoryId, branchName), result.put(String.format("%s %s %s", gitRepositoryService.findById(repositoryId).getName(),
branchName,
getTimeSeriesName()),
commitService.findByRepositoryIdAndName(repositoryId, branchName) commitService.findByRepositoryIdAndName(repositoryId, branchName)
.stream() .stream()
.map(c -> new TimeSeriesValue(c.getDate(), 1.0)) .map(c -> new TimeSeriesValue(c.getDate(), 1.0))