async indexing #88
@ -1,30 +1,39 @@
|
|||||||
package ru.ulstu.extractor.ts.creator;
|
package ru.ulstu.extractor.ts.creator;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import ru.ulstu.extractor.author.model.Author;
|
||||||
|
import ru.ulstu.extractor.author.service.AuthorService;
|
||||||
import ru.ulstu.extractor.branch.service.BranchService;
|
import ru.ulstu.extractor.branch.service.BranchService;
|
||||||
|
import ru.ulstu.extractor.commit.model.Commit;
|
||||||
|
import ru.ulstu.extractor.commit.service.CommitService;
|
||||||
import ru.ulstu.extractor.gitrepository.model.GitRepository;
|
import ru.ulstu.extractor.gitrepository.model.GitRepository;
|
||||||
import ru.ulstu.extractor.gitrepository.service.GitRepositoryService;
|
import ru.ulstu.extractor.gitrepository.service.GitRepositoryService;
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeries;
|
import ru.ulstu.extractor.ts.model.TimeSeries;
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
||||||
|
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
||||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
||||||
import ru.ulstu.extractor.ts.util.Dummy;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class AuthorsCommitTS extends AbstractTimeSeriesCreator {
|
public class AuthorsCommitTS extends AbstractTimeSeriesCreator {
|
||||||
private final TimeSeriesService timeSeriesService;
|
private final TimeSeriesService timeSeriesService;
|
||||||
|
private final CommitService commitService;
|
||||||
|
private final AuthorService authorService;
|
||||||
|
private final GitRepositoryService gitRepositoryService;
|
||||||
private final BranchService branchService;
|
private final BranchService branchService;
|
||||||
|
|
||||||
private final GitRepositoryService gitRepositoryService;
|
|
||||||
|
|
||||||
public AuthorsCommitTS(TimeSeriesService timeSeriesService,
|
public AuthorsCommitTS(TimeSeriesService timeSeriesService,
|
||||||
BranchService branchService,
|
CommitService commitService,
|
||||||
GitRepositoryService gitRepositoryService) {
|
AuthorService authorService,
|
||||||
|
GitRepositoryService gitRepositoryService,
|
||||||
|
BranchService branchService) {
|
||||||
this.timeSeriesService = timeSeriesService;
|
this.timeSeriesService = timeSeriesService;
|
||||||
this.branchService = branchService;
|
this.commitService = commitService;
|
||||||
|
this.authorService = authorService;
|
||||||
this.gitRepositoryService = gitRepositoryService;
|
this.gitRepositoryService = gitRepositoryService;
|
||||||
|
this.branchService = branchService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -34,17 +43,29 @@ public class AuthorsCommitTS extends AbstractTimeSeriesCreator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
|
public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
|
||||||
|
List<TimeSeries> timeSeriesResult = new ArrayList<>();
|
||||||
|
List<Author> authors = authorService.findAll();
|
||||||
GitRepository gitRepository = gitRepositoryService.findById(repositoryId);
|
GitRepository gitRepository = gitRepositoryService.findById(repositoryId);
|
||||||
//TODO: добавить постраничное чтение
|
List<Commit> commits = new ArrayList<>(commitService.findByRepositoryIdAndName(repositoryId, branchName));
|
||||||
return Collections.singletonList(
|
for (Author author : authors) {
|
||||||
new TimeSeries(
|
TimeSeries timeSeries = new TimeSeries(
|
||||||
String.format("%s %s %s",
|
String.format("%s %s %s %s",
|
||||||
gitRepository.getName(),
|
gitRepository.getName(),
|
||||||
branchName,
|
branchName,
|
||||||
getTimeSeriesType().getDescription()),
|
author.getName(),
|
||||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
getTimeSeriesType().getDescription()),
|
||||||
getTimeSeriesType(),
|
branchService.findByRepositoryAndName(gitRepository, branchName),
|
||||||
Dummy.getDefaultTimeSeries()));
|
getTimeSeriesType());
|
||||||
|
for (Commit commit : commits) {
|
||||||
|
if (commit.getAuthor().equals(author)) {
|
||||||
|
timeSeries.getValues().add(new TimeSeriesValue(commit.getDate(), 1.0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!timeSeries.getValues().isEmpty()) {
|
||||||
|
timeSeriesResult.add(timeSeries);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return timeSeriesResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user