fix bug merging

This commit is contained in:
f43nd1r 2018-05-29 17:26:28 +02:00
parent 43447dcbdb
commit 9012138d78
2 changed files with 4 additions and 3 deletions

View file

@ -156,7 +156,7 @@ public class DataService implements Serializable {
List<BaseBug> list = new ArrayList<>(bugs);
Bug bug = bugRepository.getOne(list.remove(0).getId());
bug.setTitle(title);
bug.setStacktraces(bugRepository.loadStacktraces(bugs));
bug.setStacktraces(bugRepository.loadStacktraces(bugs.stream().map(BaseBug::getId).collect(Collectors.toList())));
bugRepository.save(bug);
try (Stream<Report> stream = reportRepository.streamAllByBugIdIn(list.stream().map(BaseBug::getId).collect(Collectors.toList()))) {
stream.forEach(report -> {
@ -236,10 +236,12 @@ public class DataService implements Serializable {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH, -days);
reportRepository.deleteAllByBugAppAndDateBefore(app, calendar.getTime());
bugRepository.deleteOrphans();
}
public void deleteReportsBeforeVersion(@NonNull App app, int versionCode) {
reportRepository.deleteAllByBugAppAndVersionCodeLessThan(app, versionCode);
bugRepository.deleteOrphans();
}
public void delete(@NonNull App app) {

View file

@ -2,7 +2,6 @@ package com.faendir.acra.sql.data;
import com.faendir.acra.model.App;
import com.faendir.acra.model.Bug;
import com.faendir.acra.model.base.BaseBug;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
@ -23,7 +22,7 @@ public interface BugRepository extends JpaRepository<Bug, Integer> {
@SuppressWarnings("SpringDataRepositoryMethodReturnTypeInspection")
@Query("select stacktrace from Bug bug join bug.stacktraces stacktrace where bug in ?1")
List<String> loadStacktraces(Collection<? extends BaseBug> bugs);
List<String> loadStacktraces(Collection<Integer> ids);
@Query("select bug from Bug bug join fetch bug.app join fetch bug.stacktraces where bug.id = ?1")
Optional<Bug> findByIdEager(int id);