89-time-series-by-cron #90
@ -10,4 +10,8 @@ public interface GitApi {
|
|||||||
Integer getOpenIssuesCount(Branch branch);
|
Integer getOpenIssuesCount(Branch branch);
|
||||||
|
|
||||||
String getFormattedUrl(String gitRepositoryUrl, String template);
|
String getFormattedUrl(String gitRepositoryUrl, String template);
|
||||||
|
|
||||||
|
Integer getAuthorsCompletedIssues(Branch branch);
|
||||||
|
|
||||||
|
Integer getAuthorsCount(Branch branch);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@ public class GitAtheneApi implements GitApi {
|
|||||||
private static final String BRANCHES_COUNT_URL = "%s/api/v1/repos/%s/%s/branches";
|
private static final String BRANCHES_COUNT_URL = "%s/api/v1/repos/%s/%s/branches";
|
||||||
private static final String STARS_COUNT_URL = "%s/api/v1/repos/%s/%s";
|
private static final String STARS_COUNT_URL = "%s/api/v1/repos/%s/%s";
|
||||||
private static final String OPEN_ISSUES_URL = "%s/api/v1/repos/%s/%s/issues?state=open";
|
private static final String OPEN_ISSUES_URL = "%s/api/v1/repos/%s/%s/issues?state=open";
|
||||||
|
private static final String AUTHOR_COMPLETED_ISSUES_URL = "%s/api/v1/repos/%s/%s/issues?state=open";
|
||||||
|
private static final String AUTHORS_COUNT_URL = "%s/api/v1/repos/%s/%s/branches";
|
||||||
|
|
||||||
public GitAtheneApi(HttpService httpService) {
|
public GitAtheneApi(HttpService httpService) {
|
||||||
this.httpService = httpService;
|
this.httpService = httpService;
|
||||||
@ -42,4 +44,18 @@ public class GitAtheneApi implements GitApi {
|
|||||||
String[] urlParts = gitRepositoryUrl.split("/");
|
String[] urlParts = gitRepositoryUrl.split("/");
|
||||||
return String.format(template, urlParts[0] + "/" + urlParts[1] + "/" + urlParts[2], urlParts[3], urlParts[4]);
|
return String.format(template, urlParts[0] + "/" + urlParts[1] + "/" + urlParts[2], urlParts[3], urlParts[4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getAuthorsCompletedIssues(Branch branch) {
|
||||||
|
return httpService
|
||||||
|
.get(getFormattedUrl(branch.getGitRepository().getUrl(), AUTHOR_COMPLETED_ISSUES_URL))
|
||||||
|
.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getAuthorsCount(Branch branch) {
|
||||||
|
return httpService
|
||||||
|
.get(getFormattedUrl(branch.getGitRepository().getUrl(), AUTHORS_COUNT_URL))
|
||||||
|
.length();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ public class IndexService {
|
|||||||
commits = gitRepositoryService.getCommits(gitRepository.getUrl(), branch.getName(), commitsFrom, commitsTo, false);
|
commits = gitRepositoryService.getCommits(gitRepository.getUrl(), branch.getName(), commitsFrom, commitsTo, false);
|
||||||
}
|
}
|
||||||
final Branch branchForSave = branch;
|
final Branch branchForSave = branch;
|
||||||
timeSeriesCreators.forEach(tsCreator -> tsCreator.addTimeSeries(gitRepository, branchForSave));
|
timeSeriesCreators.forEach(tsCreator -> tsCreator.addTimeSeries(branchForSave));
|
||||||
branchService.updateStatus(branch, IndexingStatus.FINISHED);
|
branchService.updateStatus(branch, IndexingStatus.FINISHED);
|
||||||
LOG.debug("Complete indexing {} branch", branch.getName());
|
LOG.debug("Complete indexing {} branch", branch.getName());
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@ package ru.ulstu.extractor.ts.creator.db;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import ru.ulstu.extractor.author.model.Author;
|
import ru.ulstu.extractor.author.model.Author;
|
||||||
import ru.ulstu.extractor.author.service.AuthorService;
|
import ru.ulstu.extractor.author.service.AuthorService;
|
||||||
|
import ru.ulstu.extractor.branch.model.Branch;
|
||||||
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.model.Commit;
|
||||||
import ru.ulstu.extractor.commit.service.CommitService;
|
import ru.ulstu.extractor.commit.service.CommitService;
|
||||||
import ru.ulstu.extractor.gitrepository.model.GitRepository;
|
|
||||||
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.model.TimeSeriesValue;
|
||||||
@ -38,18 +38,20 @@ public class AuthorsCommitTS extends DBTimeSeriesCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TimeSeries> getTimeSeries(GitRepository gitRepository, String branchName) {
|
public List<TimeSeries> getTimeSeries(Branch branch) {
|
||||||
List<TimeSeries> timeSeriesResult = new ArrayList<>();
|
List<TimeSeries> timeSeriesResult = new ArrayList<>();
|
||||||
List<Author> authors = authorService.findAll();
|
List<Author> authors = authorService.findAll();
|
||||||
List<Commit> commits = new ArrayList<>(commitService.findByRepositoryIdAndName(gitRepository.getId(), branchName));
|
List<Commit> commits = new ArrayList<>(commitService.findByRepositoryIdAndName(branch.getGitRepository().getId(),
|
||||||
|
branch.getName()));
|
||||||
for (Author author : authors) {
|
for (Author author : authors) {
|
||||||
TimeSeries timeSeries = new TimeSeries(
|
TimeSeries timeSeries = new TimeSeries(
|
||||||
String.format("%s %s %s %s",
|
String.format("%s %s %s %s",
|
||||||
gitRepository.getName(),
|
branch.getGitRepository().getName(),
|
||||||
branchName,
|
branch.getName(),
|
||||||
author.getName(),
|
author.getName(),
|
||||||
getTimeSeriesType().getDescription()),
|
getTimeSeriesType().getDescription()),
|
||||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
branchService.findByRepositoryAndName(branch.getGitRepository(),
|
||||||
|
branch.getName()),
|
||||||
getTimeSeriesType());
|
getTimeSeriesType());
|
||||||
for (Commit commit : commits) {
|
for (Commit commit : commits) {
|
||||||
if (commit.getAuthor().equals(author)) {
|
if (commit.getAuthor().equals(author)) {
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package ru.ulstu.extractor.ts.creator.scheduled;
|
package ru.ulstu.extractor.ts.creator.db;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import ru.ulstu.extractor.branch.model.Branch;
|
||||||
import ru.ulstu.extractor.branch.service.BranchService;
|
import ru.ulstu.extractor.branch.service.BranchService;
|
||||||
import ru.ulstu.extractor.gitrepository.model.GitRepository;
|
|
||||||
import ru.ulstu.extractor.gitrepository.service.GitRepositoryService;
|
|
||||||
import ru.ulstu.extractor.ts.creator.AbstractTimeSeriesCreator;
|
|
||||||
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.service.TimeSeriesService;
|
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
||||||
@ -14,30 +12,25 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class ClassTS extends AbstractTimeSeriesCreator {
|
public class ClassTS extends DBTimeSeriesCreator {
|
||||||
private final TimeSeriesService timeSeriesService;
|
private final TimeSeriesService timeSeriesService;
|
||||||
private final BranchService branchService;
|
private final BranchService branchService;
|
||||||
|
|
||||||
private final GitRepositoryService gitRepositoryService;
|
|
||||||
|
|
||||||
public ClassTS(TimeSeriesService timeSeriesService,
|
public ClassTS(TimeSeriesService timeSeriesService,
|
||||||
BranchService branchService,
|
BranchService branchService) {
|
||||||
GitRepositoryService gitRepositoryService) {
|
|
||||||
this.timeSeriesService = timeSeriesService;
|
this.timeSeriesService = timeSeriesService;
|
||||||
this.branchService = branchService;
|
this.branchService = branchService;
|
||||||
this.gitRepositoryService = gitRepositoryService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
|
public List<TimeSeries> getTimeSeries(Branch branch) {
|
||||||
GitRepository gitRepository = gitRepositoryService.findById(repositoryId);
|
|
||||||
return Collections.singletonList(
|
return Collections.singletonList(
|
||||||
new TimeSeries(
|
new TimeSeries(
|
||||||
String.format("%s %s %s",
|
String.format("%s %s %s",
|
||||||
gitRepository.getName(),
|
branch.getGitRepository().getName(),
|
||||||
branchName,
|
branch.getName(),
|
||||||
getTimeSeriesType().getDescription()),
|
getTimeSeriesType().getDescription()),
|
||||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
branchService.findByRepositoryAndName(branch.getGitRepository(), branch.getName()),
|
||||||
getTimeSeriesType(),
|
getTimeSeriesType(),
|
||||||
Dummy.getDefaultTimeSeries()));
|
Dummy.getDefaultTimeSeries()));
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
package ru.ulstu.extractor.ts.creator.db;
|
package ru.ulstu.extractor.ts.creator.db;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import ru.ulstu.extractor.branch.model.Branch;
|
||||||
import ru.ulstu.extractor.branch.service.BranchService;
|
import ru.ulstu.extractor.branch.service.BranchService;
|
||||||
import ru.ulstu.extractor.commit.service.CommitService;
|
import ru.ulstu.extractor.commit.service.CommitService;
|
||||||
import ru.ulstu.extractor.gitrepository.model.GitRepository;
|
|
||||||
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.model.TimeSeriesValue;
|
||||||
@ -28,17 +28,19 @@ public class CommitsTS extends DBTimeSeriesCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TimeSeries> getTimeSeries(GitRepository gitRepository, String branchName) {
|
public List<TimeSeries> getTimeSeries(Branch branch) {
|
||||||
//TODO: добавить постраничное чтение
|
//TODO: добавить постраничное чтение
|
||||||
return Collections.singletonList(
|
return Collections.singletonList(
|
||||||
new TimeSeries(
|
new TimeSeries(
|
||||||
String.format("%s %s %s",
|
String.format("%s %s %s",
|
||||||
gitRepository.getName(),
|
branch.getGitRepository().getName(),
|
||||||
branchName,
|
branch.getName(),
|
||||||
getTimeSeriesType().getDescription()),
|
getTimeSeriesType().getDescription()),
|
||||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
branchService.findByRepositoryAndName(branch.getGitRepository(),
|
||||||
|
branch.getName()),
|
||||||
getTimeSeriesType(),
|
getTimeSeriesType(),
|
||||||
commitService.findByRepositoryIdAndName(gitRepository.getId(), branchName)
|
commitService.findByRepositoryIdAndName(branch.getGitRepository().getId(),
|
||||||
|
branch.getName())
|
||||||
.stream()
|
.stream()
|
||||||
.map(c -> new TimeSeriesValue(c.getDate(), 1.0))
|
.map(c -> new TimeSeriesValue(c.getDate(), 1.0))
|
||||||
.collect(Collectors.toList())));
|
.collect(Collectors.toList())));
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package ru.ulstu.extractor.ts.creator.db;
|
package ru.ulstu.extractor.ts.creator.db;
|
||||||
|
|
||||||
import ru.ulstu.extractor.branch.model.Branch;
|
import ru.ulstu.extractor.branch.model.Branch;
|
||||||
import ru.ulstu.extractor.gitrepository.model.GitRepository;
|
|
||||||
import ru.ulstu.extractor.ts.creator.AbstractTimeSeriesCreator;
|
import ru.ulstu.extractor.ts.creator.AbstractTimeSeriesCreator;
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeries;
|
import ru.ulstu.extractor.ts.model.TimeSeries;
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
||||||
@ -15,21 +14,19 @@ public abstract class DBTimeSeriesCreator extends AbstractTimeSeriesCreator {
|
|||||||
/**
|
/**
|
||||||
* Извлечь список точек временных рядов
|
* Извлечь список точек временных рядов
|
||||||
*
|
*
|
||||||
* @param gitRepository
|
* @param branch
|
||||||
* @param branchName
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public abstract List<TimeSeries> getTimeSeries(GitRepository gitRepository, String branchName);
|
public abstract List<TimeSeries> getTimeSeries(Branch branch);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Сохранить извлеченные временные ряды
|
* Сохранить извлеченные временные ряды
|
||||||
*
|
*
|
||||||
* @param gitRepository
|
|
||||||
* @param branch
|
* @param branch
|
||||||
*/
|
*/
|
||||||
public void addTimeSeries(GitRepository gitRepository, Branch branch) {
|
public void addTimeSeries(Branch branch) {
|
||||||
// извлеченные временных рядов
|
// извлеченные временных рядов
|
||||||
List<TimeSeries> timeSeries = getTimeSeries(gitRepository, branch.getName());
|
List<TimeSeries> timeSeries = getTimeSeries(branch);
|
||||||
|
|
||||||
// сгруппированные по временным интервалам точки временных рядов
|
// сгруппированные по временным интервалам точки временных рядов
|
||||||
timeSeries.forEach(ts -> ts.setValues(mapTimeSeriesToInterval(getTimeSeriesService().getTimeSeriesInterval(), ts.getValues())));
|
timeSeries.forEach(ts -> ts.setValues(mapTimeSeriesToInterval(getTimeSeriesService().getTimeSeriesInterval(), ts.getValues())));
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package ru.ulstu.extractor.ts.creator.scheduled;
|
package ru.ulstu.extractor.ts.creator.db;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import ru.ulstu.extractor.branch.model.Branch;
|
||||||
import ru.ulstu.extractor.branch.service.BranchService;
|
import ru.ulstu.extractor.branch.service.BranchService;
|
||||||
import ru.ulstu.extractor.gitrepository.model.GitRepository;
|
|
||||||
import ru.ulstu.extractor.gitrepository.service.GitRepositoryService;
|
|
||||||
import ru.ulstu.extractor.ts.creator.AbstractTimeSeriesCreator;
|
|
||||||
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.service.TimeSeriesService;
|
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
||||||
@ -14,30 +12,25 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DependenceTS extends AbstractTimeSeriesCreator {
|
public class DependenceTS extends DBTimeSeriesCreator {
|
||||||
private final TimeSeriesService timeSeriesService;
|
private final TimeSeriesService timeSeriesService;
|
||||||
private final BranchService branchService;
|
private final BranchService branchService;
|
||||||
|
|
||||||
private final GitRepositoryService gitRepositoryService;
|
|
||||||
|
|
||||||
public DependenceTS(TimeSeriesService timeSeriesService,
|
public DependenceTS(TimeSeriesService timeSeriesService,
|
||||||
BranchService branchService,
|
BranchService branchService) {
|
||||||
GitRepositoryService gitRepositoryService) {
|
|
||||||
this.timeSeriesService = timeSeriesService;
|
this.timeSeriesService = timeSeriesService;
|
||||||
this.branchService = branchService;
|
this.branchService = branchService;
|
||||||
this.gitRepositoryService = gitRepositoryService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
|
public List<TimeSeries> getTimeSeries(Branch branch) {
|
||||||
GitRepository gitRepository = gitRepositoryService.findById(repositoryId);
|
|
||||||
return Collections.singletonList(
|
return Collections.singletonList(
|
||||||
new TimeSeries(
|
new TimeSeries(
|
||||||
String.format("%s %s %s",
|
String.format("%s %s %s",
|
||||||
gitRepository.getName(),
|
branch.getGitRepository().getName(),
|
||||||
branchName,
|
branch.getName(),
|
||||||
getTimeSeriesType().getDescription()),
|
getTimeSeriesType().getDescription()),
|
||||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
branchService.findByRepositoryAndName(branch.getGitRepository(), branch.getName()),
|
||||||
getTimeSeriesType(),
|
getTimeSeriesType(),
|
||||||
Dummy.getDefaultTimeSeries()));
|
Dummy.getDefaultTimeSeries()));
|
||||||
}
|
}
|
@ -1,13 +1,11 @@
|
|||||||
package ru.ulstu.extractor.ts.creator.scheduled;
|
package ru.ulstu.extractor.ts.creator.db;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import ru.ulstu.extractor.branch.model.Branch;
|
||||||
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.model.Commit;
|
||||||
import ru.ulstu.extractor.commit.service.CommitService;
|
import ru.ulstu.extractor.commit.service.CommitService;
|
||||||
import ru.ulstu.extractor.gitrepository.model.FileChange;
|
import ru.ulstu.extractor.gitrepository.model.FileChange;
|
||||||
import ru.ulstu.extractor.gitrepository.model.GitRepository;
|
|
||||||
import ru.ulstu.extractor.gitrepository.service.GitRepositoryService;
|
|
||||||
import ru.ulstu.extractor.ts.creator.AbstractTimeSeriesCreator;
|
|
||||||
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.model.TimeSeriesValue;
|
||||||
@ -19,36 +17,32 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class EntityTS extends AbstractTimeSeriesCreator {
|
public class EntityTS extends DBTimeSeriesCreator {
|
||||||
private final TimeSeriesService timeSeriesService;
|
private final TimeSeriesService timeSeriesService;
|
||||||
private final CommitService commitService;
|
private final CommitService commitService;
|
||||||
private final GitRepositoryService gitRepositoryService;
|
|
||||||
private final BranchService branchService;
|
private final BranchService branchService;
|
||||||
|
|
||||||
public EntityTS(TimeSeriesService timeSeriesService,
|
public EntityTS(TimeSeriesService timeSeriesService,
|
||||||
CommitService commitService,
|
CommitService commitService,
|
||||||
GitRepositoryService gitRepositoryService,
|
|
||||||
BranchService branchService) {
|
BranchService branchService) {
|
||||||
this.timeSeriesService = timeSeriesService;
|
this.timeSeriesService = timeSeriesService;
|
||||||
this.commitService = commitService;
|
this.commitService = commitService;
|
||||||
this.gitRepositoryService = gitRepositoryService;
|
|
||||||
this.branchService = branchService;
|
this.branchService = branchService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
|
public List<TimeSeries> getTimeSeries(Branch branch) {
|
||||||
GitRepository gitRepository = gitRepositoryService.findById(repositoryId);
|
|
||||||
return Collections.singletonList(
|
return Collections.singletonList(
|
||||||
new TimeSeries(
|
new TimeSeries(
|
||||||
String.format("%s %s %s",
|
String.format("%s %s %s",
|
||||||
gitRepository.getName(),
|
branch.getGitRepository().getName(),
|
||||||
branchName,
|
branch.getName(),
|
||||||
getTimeSeriesType().getDescription()),
|
getTimeSeriesType().getDescription()),
|
||||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
branchService.findByRepositoryAndName(branch.getGitRepository(), branch.getName()),
|
||||||
getTimeSeriesType(),
|
getTimeSeriesType(),
|
||||||
commitService.findByRepositoryIdAndName(repositoryId, branchName)
|
commitService.findByRepositoryIdAndName(branch.getGitRepository().getId(), branch.getName())
|
||||||
.stream()
|
.stream()
|
||||||
.map(c -> new TimeSeriesValue(c.getDate(), findEntity(repositoryId, branchName)))
|
.map(c -> new TimeSeriesValue(c.getDate(), findEntity(branch.getGitRepository().getId(), branch.getName())))
|
||||||
.collect(Collectors.toList())));
|
.collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +1,11 @@
|
|||||||
package ru.ulstu.extractor.ts.creator.db;
|
package ru.ulstu.extractor.ts.creator.db;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import ru.ulstu.extractor.branch.model.Branch;
|
||||||
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.model.Commit;
|
||||||
import ru.ulstu.extractor.commit.service.CommitService;
|
import ru.ulstu.extractor.commit.service.CommitService;
|
||||||
import ru.ulstu.extractor.gitrepository.model.FileChange;
|
import ru.ulstu.extractor.gitrepository.model.FileChange;
|
||||||
import ru.ulstu.extractor.gitrepository.model.GitRepository;
|
|
||||||
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.model.TimeSeriesValue;
|
||||||
@ -29,16 +29,18 @@ public class FileTS extends DBTimeSeriesCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TimeSeries> getTimeSeries(GitRepository gitRepository, String branchName) {
|
public List<TimeSeries> getTimeSeries(Branch branch) {
|
||||||
List<TimeSeries> timeSeriesResult = new ArrayList<>();
|
List<TimeSeries> timeSeriesResult = new ArrayList<>();
|
||||||
List<Commit> commits = new ArrayList<>(commitService.findByRepositoryIdAndName(gitRepository.getId(), branchName));
|
List<Commit> commits = new ArrayList<>(commitService.findByRepositoryIdAndName(branch.getGitRepository().getId(),
|
||||||
|
branch.getName()));
|
||||||
double value = 0;
|
double value = 0;
|
||||||
TimeSeries timeSeries = new TimeSeries(
|
TimeSeries timeSeries = new TimeSeries(
|
||||||
String.format("%s %s %s",
|
String.format("%s %s %s",
|
||||||
gitRepository.getName(),
|
branch.getGitRepository().getName(),
|
||||||
branchName,
|
branch.getName(),
|
||||||
getTimeSeriesType().getDescription()),
|
getTimeSeriesType().getDescription()),
|
||||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
branchService.findByRepositoryAndName(branch.getGitRepository(),
|
||||||
|
branch.getName()),
|
||||||
getTimeSeriesType());
|
getTimeSeriesType());
|
||||||
for (Commit commit : commits) {
|
for (Commit commit : commits) {
|
||||||
for (FileChange fileChange : commit.getFileChanges()) {
|
for (FileChange fileChange : commit.getFileChanges()) {
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package ru.ulstu.extractor.ts.creator.scheduled;
|
package ru.ulstu.extractor.ts.creator.db;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import ru.ulstu.extractor.branch.model.Branch;
|
||||||
import ru.ulstu.extractor.branch.service.BranchService;
|
import ru.ulstu.extractor.branch.service.BranchService;
|
||||||
import ru.ulstu.extractor.gitrepository.model.GitRepository;
|
|
||||||
import ru.ulstu.extractor.gitrepository.service.GitRepositoryService;
|
|
||||||
import ru.ulstu.extractor.ts.creator.AbstractTimeSeriesCreator;
|
|
||||||
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.service.TimeSeriesService;
|
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
||||||
@ -14,30 +12,25 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class InterfaceTS extends AbstractTimeSeriesCreator {
|
public class InterfaceTS extends DBTimeSeriesCreator {
|
||||||
private final TimeSeriesService timeSeriesService;
|
private final TimeSeriesService timeSeriesService;
|
||||||
private final BranchService branchService;
|
private final BranchService branchService;
|
||||||
|
|
||||||
private final GitRepositoryService gitRepositoryService;
|
|
||||||
|
|
||||||
public InterfaceTS(TimeSeriesService timeSeriesService,
|
public InterfaceTS(TimeSeriesService timeSeriesService,
|
||||||
BranchService branchService,
|
BranchService branchService) {
|
||||||
GitRepositoryService gitRepositoryService) {
|
|
||||||
this.timeSeriesService = timeSeriesService;
|
this.timeSeriesService = timeSeriesService;
|
||||||
this.branchService = branchService;
|
this.branchService = branchService;
|
||||||
this.gitRepositoryService = gitRepositoryService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
|
public List<TimeSeries> getTimeSeries(Branch branch) {
|
||||||
GitRepository gitRepository = gitRepositoryService.findById(repositoryId);
|
|
||||||
return Collections.singletonList(
|
return Collections.singletonList(
|
||||||
new TimeSeries(
|
new TimeSeries(
|
||||||
String.format("%s %s %s",
|
String.format("%s %s %s",
|
||||||
gitRepository.getName(),
|
branch.getGitRepository().getName(),
|
||||||
branchName,
|
branch.getName(),
|
||||||
getTimeSeriesType().getDescription()),
|
getTimeSeriesType().getDescription()),
|
||||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
branchService.findByRepositoryAndName(branch.getGitRepository(), branch.getName()),
|
||||||
getTimeSeriesType(),
|
getTimeSeriesType(),
|
||||||
Dummy.getDefaultTimeSeries()));
|
Dummy.getDefaultTimeSeries()));
|
||||||
}
|
}
|
@ -1,9 +1,8 @@
|
|||||||
package ru.ulstu.extractor.ts.creator.scheduled;
|
package ru.ulstu.extractor.ts.creator.db;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import ru.ulstu.extractor.branch.model.Branch;
|
||||||
import ru.ulstu.extractor.branch.service.BranchService;
|
import ru.ulstu.extractor.branch.service.BranchService;
|
||||||
import ru.ulstu.extractor.gitrepository.model.GitRepository;
|
|
||||||
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.service.TimeSeriesService;
|
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
||||||
@ -13,30 +12,25 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class ProcessTS extends ScheduledTimeSeriesCreator {
|
public class ProcessTS extends DBTimeSeriesCreator {
|
||||||
private final TimeSeriesService timeSeriesService;
|
private final TimeSeriesService timeSeriesService;
|
||||||
private final BranchService branchService;
|
private final BranchService branchService;
|
||||||
|
|
||||||
private final GitRepositoryService gitRepositoryService;
|
|
||||||
|
|
||||||
public ProcessTS(TimeSeriesService timeSeriesService,
|
public ProcessTS(TimeSeriesService timeSeriesService,
|
||||||
BranchService branchService,
|
BranchService branchService) {
|
||||||
GitRepositoryService gitRepositoryService) {
|
|
||||||
this.timeSeriesService = timeSeriesService;
|
this.timeSeriesService = timeSeriesService;
|
||||||
this.branchService = branchService;
|
this.branchService = branchService;
|
||||||
this.gitRepositoryService = gitRepositoryService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
|
public List<TimeSeries> getTimeSeries(Branch branch) {
|
||||||
GitRepository gitRepository = gitRepositoryService.findById(repositoryId);
|
|
||||||
return Collections.singletonList(
|
return Collections.singletonList(
|
||||||
new TimeSeries(
|
new TimeSeries(
|
||||||
String.format("%s %s %s",
|
String.format("%s %s %s",
|
||||||
gitRepository.getName(),
|
branch.getGitRepository().getName(),
|
||||||
branchName,
|
branch.getName(),
|
||||||
getTimeSeriesType().getDescription()),
|
getTimeSeriesType().getDescription()),
|
||||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
branchService.findByRepositoryAndName(branch.getGitRepository(), branch.getName()),
|
||||||
getTimeSeriesType(),
|
getTimeSeriesType(),
|
||||||
Dummy.getDefaultTimeSeries()));
|
Dummy.getDefaultTimeSeries()));
|
||||||
}
|
}
|
@ -1,38 +1,20 @@
|
|||||||
package ru.ulstu.extractor.ts.creator.scheduled;
|
package ru.ulstu.extractor.ts.creator.scheduled;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import ru.ulstu.extractor.author.model.Author;
|
import ru.ulstu.extractor.branch.model.Branch;
|
||||||
import ru.ulstu.extractor.author.service.AuthorService;
|
import ru.ulstu.extractor.gitrepository.service.GitApi;
|
||||||
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.service.GitRepositoryService;
|
|
||||||
import ru.ulstu.extractor.ts.creator.db.DBTimeSeriesCreator;
|
|
||||||
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.model.TimeSeriesValue;
|
||||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class AuthorTS extends DBTimeSeriesCreator {
|
public class AuthorTS extends ScheduledTimeSeriesCreator {
|
||||||
private final TimeSeriesService timeSeriesService;
|
private final TimeSeriesService timeSeriesService;
|
||||||
private final CommitService commitService;
|
private final GitApi gitApi;
|
||||||
private final AuthorService authorService;
|
|
||||||
private final BranchService branchService;
|
|
||||||
|
|
||||||
public AuthorTS(TimeSeriesService timeSeriesService,
|
public AuthorTS(TimeSeriesService timeSeriesService, GitApi gitApi) {
|
||||||
CommitService commitService,
|
|
||||||
AuthorService authorService,
|
|
||||||
GitRepositoryService gitRepositoryService,
|
|
||||||
BranchService branchService) {
|
|
||||||
this.timeSeriesService = timeSeriesService;
|
this.timeSeriesService = timeSeriesService;
|
||||||
this.commitService = commitService;
|
this.gitApi = gitApi;
|
||||||
this.authorService = authorService;
|
|
||||||
this.branchService = branchService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -41,29 +23,8 @@ public class AuthorTS extends DBTimeSeriesCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TimeSeries> getTimeSeries(GitRepository gitRepository, String branchName) {
|
public TimeSeriesValue getNewTimeSeriesValue(Branch branch) {
|
||||||
List<TimeSeries> timeSeriesResult = new ArrayList<>();
|
return new TimeSeriesValue(gitApi.getAuthorsCount(branch));
|
||||||
List<Author> authors = authorService.findAll();
|
|
||||||
List<Commit> commits = new ArrayList<>(commitService.findByRepositoryIdAndName(gitRepository.getId(), branchName));
|
|
||||||
for (Author author : authors) {
|
|
||||||
TimeSeries timeSeries = new TimeSeries(
|
|
||||||
String.format("%s %s %s %s",
|
|
||||||
gitRepository.getName(),
|
|
||||||
branchName,
|
|
||||||
author.getName(),
|
|
||||||
getTimeSeriesType().getDescription()),
|
|
||||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
|
||||||
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
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
package ru.ulstu.extractor.ts.creator.scheduled;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import ru.ulstu.extractor.branch.service.BranchService;
|
|
||||||
import ru.ulstu.extractor.gitrepository.model.GitRepository;
|
|
||||||
import ru.ulstu.extractor.gitrepository.service.GitRepositoryService;
|
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeries;
|
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
|
||||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
|
||||||
import ru.ulstu.extractor.ts.util.Dummy;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class AuthorsCompletedIssueTS extends ScheduledTimeSeriesCreator {
|
|
||||||
private final TimeSeriesService timeSeriesService;
|
|
||||||
private final BranchService branchService;
|
|
||||||
|
|
||||||
private final GitRepositoryService gitRepositoryService;
|
|
||||||
|
|
||||||
public AuthorsCompletedIssueTS(TimeSeriesService timeSeriesService,
|
|
||||||
BranchService branchService,
|
|
||||||
GitRepositoryService gitRepositoryService) {
|
|
||||||
this.timeSeriesService = timeSeriesService;
|
|
||||||
this.branchService = branchService;
|
|
||||||
this.gitRepositoryService = gitRepositoryService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<TimeSeries> getTimeSeries(GitRepository gitRepository, String branchName) {
|
|
||||||
//TODO: добавить постраничное чтение
|
|
||||||
return Collections.singletonList(
|
|
||||||
new TimeSeries(
|
|
||||||
String.format("%s %s %s",
|
|
||||||
gitRepository.getName(),
|
|
||||||
branchName,
|
|
||||||
getTimeSeriesType().getDescription()),
|
|
||||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
|
||||||
getTimeSeriesType(),
|
|
||||||
Dummy.getDefaultTimeSeries()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TimeSeriesService getTimeSeriesService() {
|
|
||||||
return timeSeriesService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TimeSeriesType getTimeSeriesType() {
|
|
||||||
return TimeSeriesType.AUTHOR_COMPLETED_ISSUES;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
package ru.ulstu.extractor.ts.creator.scheduled;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import ru.ulstu.extractor.branch.service.BranchService;
|
|
||||||
import ru.ulstu.extractor.gitrepository.model.GitRepository;
|
|
||||||
import ru.ulstu.extractor.gitrepository.service.GitRepositoryService;
|
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeries;
|
|
||||||
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
|
||||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
|
||||||
import ru.ulstu.extractor.ts.util.Dummy;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class AuthorsIssueTS extends ScheduledTimeSeriesCreator {
|
|
||||||
private final TimeSeriesService timeSeriesService;
|
|
||||||
private final BranchService branchService;
|
|
||||||
|
|
||||||
private final GitRepositoryService gitRepositoryService;
|
|
||||||
|
|
||||||
public AuthorsIssueTS(TimeSeriesService timeSeriesService,
|
|
||||||
BranchService branchService,
|
|
||||||
GitRepositoryService gitRepositoryService) {
|
|
||||||
this.timeSeriesService = timeSeriesService;
|
|
||||||
this.branchService = branchService;
|
|
||||||
this.gitRepositoryService = gitRepositoryService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
|
|
||||||
GitRepository gitRepository = gitRepositoryService.findById(repositoryId);
|
|
||||||
return Collections.singletonList(
|
|
||||||
new TimeSeries(
|
|
||||||
String.format("%s %s %s",
|
|
||||||
gitRepository.getName(),
|
|
||||||
branchName,
|
|
||||||
getTimeSeriesType().getDescription()),
|
|
||||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
|
||||||
getTimeSeriesType(),
|
|
||||||
Dummy.getDefaultTimeSeries()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TimeSeriesService getTimeSeriesService() {
|
|
||||||
return timeSeriesService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TimeSeriesType getTimeSeriesType() {
|
|
||||||
return TimeSeriesType.AUTHOR_ISSUES;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user