|
|
|
@ -5,6 +5,7 @@
|
|
|
|
|
|
|
|
|
|
package ru.ulstu.extractor.service;
|
|
|
|
|
|
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import ru.ulstu.extractor.model.Commit;
|
|
|
|
|
import ru.ulstu.extractor.repository.CommitRepository;
|
|
|
|
@ -14,16 +15,16 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class CommitService {
|
|
|
|
|
private final GitRepositoryService gitRepositoryService;
|
|
|
|
|
private final CommitRepository commitRepository;
|
|
|
|
|
private final AuthorService authorService;
|
|
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
|
|
|
|
public CommitService(GitRepositoryService gitRepositoryService,
|
|
|
|
|
CommitRepository commitRepository,
|
|
|
|
|
AuthorService authorService) {
|
|
|
|
|
this.gitRepositoryService = gitRepositoryService;
|
|
|
|
|
public CommitService(CommitRepository commitRepository,
|
|
|
|
|
AuthorService authorService,
|
|
|
|
|
JdbcTemplate jdbcTemplate) {
|
|
|
|
|
this.commitRepository = commitRepository;
|
|
|
|
|
this.authorService = authorService;
|
|
|
|
|
this.jdbcTemplate = jdbcTemplate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void delete(List<Commit> commitsToRemove) {
|
|
|
|
@ -41,6 +42,13 @@ public class CommitService {
|
|
|
|
|
public void deleteWithEmptyIds() {
|
|
|
|
|
commitRepository.deleteByBranchIsNull();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateBranchId(List<Commit> commits, Integer branchId) {
|
|
|
|
|
List<String> commitIds = commits.stream().map(c -> c.getId().toString()).collect(Collectors.toList());
|
|
|
|
|
String updateQuery = "update commit set branch_id = ? where id in (%s)";
|
|
|
|
|
updateQuery = String.format(updateQuery, String.join(",", commitIds));
|
|
|
|
|
jdbcTemplate.update(updateQuery, branchId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|