diff --git a/src/main/java/mediathek/filmlisten/reader/FilmListReader.java b/src/main/java/mediathek/filmlisten/reader/FilmListReader.java index 906886549d..25baca7a65 100644 --- a/src/main/java/mediathek/filmlisten/reader/FilmListReader.java +++ b/src/main/java/mediathek/filmlisten/reader/FilmListReader.java @@ -47,6 +47,7 @@ import java.time.format.DateTimeFormatter; import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @@ -383,14 +384,17 @@ private void printDuplicateStatistics(@NotNull ListeFilme listeFilme) { final var duplicates = listeFilme.parallelStream() .filter(DatenFilm::isDuplicate) .toList(); - final var senders = duplicates.parallelStream().map(DatenFilm::getSender).distinct().toList(); + var statisticsEventList = Daten.getInstance().getFilmListDuplicateStatisticsList(); - for (var sender: senders) { - final var dupes = duplicates.parallelStream().filter(f -> f.getSender().equals(sender)).count(); - statisticsEventList.add(new DuplicateStatistics(sender, dupes)); + + Map statisticsMap = duplicates.parallelStream().collect(Collectors.groupingBy(DatenFilm::getSender, Collectors.counting())); + statisticsEventList.getReadWriteLock().writeLock().lock(); + for (var sender : statisticsMap.keySet()) { + statisticsEventList.add(new DuplicateStatistics(sender, statisticsMap.get(sender))); } + statisticsEventList.getReadWriteLock().writeLock().unlock(); watch.stop(); - logger.trace(statisticsEventList.toString()); + //logger.trace(statisticsEventList.toString()); long dupes = 0; for (var item : statisticsEventList) { dupes += item.count;