|
|
|
@ -9,8 +9,11 @@ import com.sun.istack.NotNull;
|
|
|
|
|
import org.eclipse.jgit.api.errors.GitAPIException;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import ru.ulstu.extractor.branch.model.Branch;
|
|
|
|
|
import ru.ulstu.extractor.branch.model.IndexingStatus;
|
|
|
|
|
import ru.ulstu.extractor.branch.service.BranchService;
|
|
|
|
|
import ru.ulstu.extractor.commit.model.Commit;
|
|
|
|
|
import ru.ulstu.extractor.gitrepository.model.GitRepository;
|
|
|
|
@ -55,6 +58,7 @@ public class IndexService {
|
|
|
|
|
branch = new Branch(gitRepository, branchName);
|
|
|
|
|
}
|
|
|
|
|
branchService.save(branch, Collections.emptyList());
|
|
|
|
|
branch = branchService.updateStatus(branch, IndexingStatus.INDEXING);
|
|
|
|
|
int commitsFrom = 0;
|
|
|
|
|
int commitsTo = COMMITS_PAGE_SIZE;
|
|
|
|
|
List<Commit> commits = gitRepositoryService.getCommits(repositoryUrl, branchName, commitsFrom, commitsTo, true);
|
|
|
|
@ -69,6 +73,30 @@ public class IndexService {
|
|
|
|
|
Integer repositoryId = gitRepository.getId();
|
|
|
|
|
final Branch branchForSave = branch;
|
|
|
|
|
timeSeriesCreators.forEach(tsCreator -> tsCreator.addTimeSeries(repositoryId, branchForSave));
|
|
|
|
|
branchService.updateStatus(branch, IndexingStatus.FINISHED);
|
|
|
|
|
LOG.debug("Complete indexing {} branch", branchName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
@Async
|
|
|
|
|
public void indexFailedBranchesOnStart() {
|
|
|
|
|
LOG.info("Старт проверки незавершенных задач для индексирований...");
|
|
|
|
|
|
|
|
|
|
List<Branch> failedBranches = branchService.findAllByIndexingStatus(IndexingStatus.INDEXING);
|
|
|
|
|
if (failedBranches.size() > 0) {
|
|
|
|
|
LOG.info("Найдено {} незавершенных задач для индексирования", failedBranches.size());
|
|
|
|
|
failedBranches.forEach(failedBranch -> {
|
|
|
|
|
try {
|
|
|
|
|
index(failedBranch.getId());
|
|
|
|
|
LOG.info("Завершено индексирование ветки {}", failedBranch.getName());
|
|
|
|
|
branchService.updateStatus(failedBranch, IndexingStatus.FINISHED);
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
LOG.warn(ex.getMessage());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
LOG.info("Завершено индексирование незавершенных задач");
|
|
|
|
|
} else {
|
|
|
|
|
LOG.info("Не найдено незавершенных веток для индексирования");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|