#89 -- Create a valid class hierarchy
This commit is contained in:
parent
0d43bf8ccd
commit
aeab50cfb8
@ -10,4 +10,8 @@ public interface GitApi {
|
||||
Integer getOpenIssuesCount(Branch branch);
|
||||
|
||||
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 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 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) {
|
||||
this.httpService = httpService;
|
||||
@ -42,4 +44,18 @@ public class GitAtheneApi implements GitApi {
|
||||
String[] urlParts = gitRepositoryUrl.split("/");
|
||||
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);
|
||||
}
|
||||
final Branch branchForSave = branch;
|
||||
timeSeriesCreators.forEach(tsCreator -> tsCreator.addTimeSeries(gitRepository, branchForSave));
|
||||
timeSeriesCreators.forEach(tsCreator -> tsCreator.addTimeSeries(branchForSave));
|
||||
branchService.updateStatus(branch, IndexingStatus.FINISHED);
|
||||
LOG.debug("Complete indexing {} branch", branch.getName());
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ package ru.ulstu.extractor.ts.creator.db;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.ulstu.extractor.author.model.Author;
|
||||
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.commit.model.Commit;
|
||||
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.TimeSeriesType;
|
||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
||||
@ -38,18 +38,20 @@ public class AuthorsCommitTS extends DBTimeSeriesCreator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TimeSeries> getTimeSeries(GitRepository gitRepository, String branchName) {
|
||||
public List<TimeSeries> getTimeSeries(Branch branch) {
|
||||
List<TimeSeries> timeSeriesResult = new ArrayList<>();
|
||||
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) {
|
||||
TimeSeries timeSeries = new TimeSeries(
|
||||
String.format("%s %s %s %s",
|
||||
gitRepository.getName(),
|
||||
branchName,
|
||||
branch.getGitRepository().getName(),
|
||||
branch.getName(),
|
||||
author.getName(),
|
||||
getTimeSeriesType().getDescription()),
|
||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
||||
branchService.findByRepositoryAndName(branch.getGitRepository(),
|
||||
branch.getName()),
|
||||
getTimeSeriesType());
|
||||
for (Commit commit : commits) {
|
||||
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 ru.ulstu.extractor.branch.model.Branch;
|
||||
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.TimeSeriesType;
|
||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
||||
@ -14,30 +12,25 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class ClassTS extends AbstractTimeSeriesCreator {
|
||||
public class ClassTS extends DBTimeSeriesCreator {
|
||||
private final TimeSeriesService timeSeriesService;
|
||||
private final BranchService branchService;
|
||||
|
||||
private final GitRepositoryService gitRepositoryService;
|
||||
|
||||
public ClassTS(TimeSeriesService timeSeriesService,
|
||||
BranchService branchService,
|
||||
GitRepositoryService gitRepositoryService) {
|
||||
BranchService branchService) {
|
||||
this.timeSeriesService = timeSeriesService;
|
||||
this.branchService = branchService;
|
||||
this.gitRepositoryService = gitRepositoryService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
|
||||
GitRepository gitRepository = gitRepositoryService.findById(repositoryId);
|
||||
public List<TimeSeries> getTimeSeries(Branch branch) {
|
||||
return Collections.singletonList(
|
||||
new TimeSeries(
|
||||
String.format("%s %s %s",
|
||||
gitRepository.getName(),
|
||||
branchName,
|
||||
branch.getGitRepository().getName(),
|
||||
branch.getName(),
|
||||
getTimeSeriesType().getDescription()),
|
||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
||||
branchService.findByRepositoryAndName(branch.getGitRepository(), branch.getName()),
|
||||
getTimeSeriesType(),
|
||||
Dummy.getDefaultTimeSeries()));
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package ru.ulstu.extractor.ts.creator.db;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.ulstu.extractor.branch.model.Branch;
|
||||
import ru.ulstu.extractor.branch.service.BranchService;
|
||||
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.TimeSeriesType;
|
||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
||||
@ -28,17 +28,19 @@ public class CommitsTS extends DBTimeSeriesCreator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TimeSeries> getTimeSeries(GitRepository gitRepository, String branchName) {
|
||||
public List<TimeSeries> getTimeSeries(Branch branch) {
|
||||
//TODO: добавить постраничное чтение
|
||||
return Collections.singletonList(
|
||||
new TimeSeries(
|
||||
String.format("%s %s %s",
|
||||
gitRepository.getName(),
|
||||
branchName,
|
||||
branch.getGitRepository().getName(),
|
||||
branch.getName(),
|
||||
getTimeSeriesType().getDescription()),
|
||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
||||
branchService.findByRepositoryAndName(branch.getGitRepository(),
|
||||
branch.getName()),
|
||||
getTimeSeriesType(),
|
||||
commitService.findByRepositoryIdAndName(gitRepository.getId(), branchName)
|
||||
commitService.findByRepositoryIdAndName(branch.getGitRepository().getId(),
|
||||
branch.getName())
|
||||
.stream()
|
||||
.map(c -> new TimeSeriesValue(c.getDate(), 1.0))
|
||||
.collect(Collectors.toList())));
|
||||
|
@ -1,7 +1,6 @@
|
||||
package ru.ulstu.extractor.ts.creator.db;
|
||||
|
||||
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.model.TimeSeries;
|
||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
||||
@ -15,21 +14,19 @@ public abstract class DBTimeSeriesCreator extends AbstractTimeSeriesCreator {
|
||||
/**
|
||||
* Извлечь список точек временных рядов
|
||||
*
|
||||
* @param gitRepository
|
||||
* @param branchName
|
||||
* @param branch
|
||||
* @return
|
||||
*/
|
||||
public abstract List<TimeSeries> getTimeSeries(GitRepository gitRepository, String branchName);
|
||||
public abstract List<TimeSeries> getTimeSeries(Branch branch);
|
||||
|
||||
/**
|
||||
* Сохранить извлеченные временные ряды
|
||||
*
|
||||
* @param gitRepository
|
||||
* @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())));
|
||||
|
@ -1,10 +1,8 @@
|
||||
package ru.ulstu.extractor.ts.creator.scheduled;
|
||||
package ru.ulstu.extractor.ts.creator.db;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.ulstu.extractor.branch.model.Branch;
|
||||
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.TimeSeriesType;
|
||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
||||
@ -14,30 +12,25 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class DependenceTS extends AbstractTimeSeriesCreator {
|
||||
public class DependenceTS extends DBTimeSeriesCreator {
|
||||
private final TimeSeriesService timeSeriesService;
|
||||
private final BranchService branchService;
|
||||
|
||||
private final GitRepositoryService gitRepositoryService;
|
||||
|
||||
public DependenceTS(TimeSeriesService timeSeriesService,
|
||||
BranchService branchService,
|
||||
GitRepositoryService gitRepositoryService) {
|
||||
BranchService branchService) {
|
||||
this.timeSeriesService = timeSeriesService;
|
||||
this.branchService = branchService;
|
||||
this.gitRepositoryService = gitRepositoryService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
|
||||
GitRepository gitRepository = gitRepositoryService.findById(repositoryId);
|
||||
public List<TimeSeries> getTimeSeries(Branch branch) {
|
||||
return Collections.singletonList(
|
||||
new TimeSeries(
|
||||
String.format("%s %s %s",
|
||||
gitRepository.getName(),
|
||||
branchName,
|
||||
branch.getGitRepository().getName(),
|
||||
branch.getName(),
|
||||
getTimeSeriesType().getDescription()),
|
||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
||||
branchService.findByRepositoryAndName(branch.getGitRepository(), branch.getName()),
|
||||
getTimeSeriesType(),
|
||||
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 ru.ulstu.extractor.branch.model.Branch;
|
||||
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.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.TimeSeriesType;
|
||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
||||
@ -19,36 +17,32 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class EntityTS extends AbstractTimeSeriesCreator {
|
||||
public class EntityTS extends DBTimeSeriesCreator {
|
||||
private final TimeSeriesService timeSeriesService;
|
||||
private final CommitService commitService;
|
||||
private final GitRepositoryService gitRepositoryService;
|
||||
private final BranchService branchService;
|
||||
|
||||
public EntityTS(TimeSeriesService timeSeriesService,
|
||||
CommitService commitService,
|
||||
GitRepositoryService gitRepositoryService,
|
||||
BranchService branchService) {
|
||||
this.timeSeriesService = timeSeriesService;
|
||||
this.commitService = commitService;
|
||||
this.gitRepositoryService = gitRepositoryService;
|
||||
this.branchService = branchService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
|
||||
GitRepository gitRepository = gitRepositoryService.findById(repositoryId);
|
||||
public List<TimeSeries> getTimeSeries(Branch branch) {
|
||||
return Collections.singletonList(
|
||||
new TimeSeries(
|
||||
String.format("%s %s %s",
|
||||
gitRepository.getName(),
|
||||
branchName,
|
||||
branch.getGitRepository().getName(),
|
||||
branch.getName(),
|
||||
getTimeSeriesType().getDescription()),
|
||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
||||
branchService.findByRepositoryAndName(branch.getGitRepository(), branch.getName()),
|
||||
getTimeSeriesType(),
|
||||
commitService.findByRepositoryIdAndName(repositoryId, branchName)
|
||||
commitService.findByRepositoryIdAndName(branch.getGitRepository().getId(), branch.getName())
|
||||
.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())));
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package ru.ulstu.extractor.ts.creator.db;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.ulstu.extractor.branch.model.Branch;
|
||||
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.FileChange;
|
||||
import ru.ulstu.extractor.gitrepository.model.GitRepository;
|
||||
import ru.ulstu.extractor.ts.model.TimeSeries;
|
||||
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
||||
@ -29,16 +29,18 @@ public class FileTS extends DBTimeSeriesCreator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TimeSeries> getTimeSeries(GitRepository gitRepository, String branchName) {
|
||||
public List<TimeSeries> getTimeSeries(Branch branch) {
|
||||
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;
|
||||
TimeSeries timeSeries = new TimeSeries(
|
||||
String.format("%s %s %s",
|
||||
gitRepository.getName(),
|
||||
branchName,
|
||||
branch.getGitRepository().getName(),
|
||||
branch.getName(),
|
||||
getTimeSeriesType().getDescription()),
|
||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
||||
branchService.findByRepositoryAndName(branch.getGitRepository(),
|
||||
branch.getName()),
|
||||
getTimeSeriesType());
|
||||
for (Commit commit : commits) {
|
||||
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 ru.ulstu.extractor.branch.model.Branch;
|
||||
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.TimeSeriesType;
|
||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
||||
@ -14,30 +12,25 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class InterfaceTS extends AbstractTimeSeriesCreator {
|
||||
public class InterfaceTS extends DBTimeSeriesCreator {
|
||||
private final TimeSeriesService timeSeriesService;
|
||||
private final BranchService branchService;
|
||||
|
||||
private final GitRepositoryService gitRepositoryService;
|
||||
|
||||
public InterfaceTS(TimeSeriesService timeSeriesService,
|
||||
BranchService branchService,
|
||||
GitRepositoryService gitRepositoryService) {
|
||||
BranchService branchService) {
|
||||
this.timeSeriesService = timeSeriesService;
|
||||
this.branchService = branchService;
|
||||
this.gitRepositoryService = gitRepositoryService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
|
||||
GitRepository gitRepository = gitRepositoryService.findById(repositoryId);
|
||||
public List<TimeSeries> getTimeSeries(Branch branch) {
|
||||
return Collections.singletonList(
|
||||
new TimeSeries(
|
||||
String.format("%s %s %s",
|
||||
gitRepository.getName(),
|
||||
branchName,
|
||||
branch.getGitRepository().getName(),
|
||||
branch.getName(),
|
||||
getTimeSeriesType().getDescription()),
|
||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
||||
branchService.findByRepositoryAndName(branch.getGitRepository(), branch.getName()),
|
||||
getTimeSeriesType(),
|
||||
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 ru.ulstu.extractor.branch.model.Branch;
|
||||
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;
|
||||
@ -13,30 +12,25 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class ProcessTS extends ScheduledTimeSeriesCreator {
|
||||
public class ProcessTS extends DBTimeSeriesCreator {
|
||||
private final TimeSeriesService timeSeriesService;
|
||||
private final BranchService branchService;
|
||||
|
||||
private final GitRepositoryService gitRepositoryService;
|
||||
|
||||
public ProcessTS(TimeSeriesService timeSeriesService,
|
||||
BranchService branchService,
|
||||
GitRepositoryService gitRepositoryService) {
|
||||
BranchService branchService) {
|
||||
this.timeSeriesService = timeSeriesService;
|
||||
this.branchService = branchService;
|
||||
this.gitRepositoryService = gitRepositoryService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TimeSeries> getTimeSeries(Integer repositoryId, String branchName) {
|
||||
GitRepository gitRepository = gitRepositoryService.findById(repositoryId);
|
||||
public List<TimeSeries> getTimeSeries(Branch branch) {
|
||||
return Collections.singletonList(
|
||||
new TimeSeries(
|
||||
String.format("%s %s %s",
|
||||
gitRepository.getName(),
|
||||
branchName,
|
||||
branch.getGitRepository().getName(),
|
||||
branch.getName(),
|
||||
getTimeSeriesType().getDescription()),
|
||||
branchService.findByRepositoryAndName(gitRepository, branchName),
|
||||
branchService.findByRepositoryAndName(branch.getGitRepository(), branch.getName()),
|
||||
getTimeSeriesType(),
|
||||
Dummy.getDefaultTimeSeries()));
|
||||
}
|
@ -1,38 +1,20 @@
|
||||
package ru.ulstu.extractor.ts.creator.scheduled;
|
||||
|
||||
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.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.branch.model.Branch;
|
||||
import ru.ulstu.extractor.gitrepository.service.GitApi;
|
||||
import ru.ulstu.extractor.ts.model.TimeSeriesType;
|
||||
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
|
||||
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class AuthorTS extends DBTimeSeriesCreator {
|
||||
public class AuthorTS extends ScheduledTimeSeriesCreator {
|
||||
private final TimeSeriesService timeSeriesService;
|
||||
private final CommitService commitService;
|
||||
private final AuthorService authorService;
|
||||
private final BranchService branchService;
|
||||
private final GitApi gitApi;
|
||||
|
||||
public AuthorTS(TimeSeriesService timeSeriesService,
|
||||
CommitService commitService,
|
||||
AuthorService authorService,
|
||||
GitRepositoryService gitRepositoryService,
|
||||
BranchService branchService) {
|
||||
public AuthorTS(TimeSeriesService timeSeriesService, GitApi gitApi) {
|
||||
this.timeSeriesService = timeSeriesService;
|
||||
this.commitService = commitService;
|
||||
this.authorService = authorService;
|
||||
this.branchService = branchService;
|
||||
this.gitApi = gitApi;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -41,29 +23,8 @@ public class AuthorTS extends DBTimeSeriesCreator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TimeSeries> getTimeSeries(GitRepository gitRepository, String branchName) {
|
||||
List<TimeSeries> timeSeriesResult = new ArrayList<>();
|
||||
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;
|
||||
public TimeSeriesValue getNewTimeSeriesValue(Branch branch) {
|
||||
return new TimeSeriesValue(gitApi.getAuthorsCount(branch));
|
||||
}
|
||||
|
||||
@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