From 5860b7eadebaf3a3d23a98e21f92a51f88140b7d Mon Sep 17 00:00:00 2001 From: "Christian F." Date: Mon, 21 Oct 2024 16:12:36 +0200 Subject: [PATCH] - always perform duplicate check when reading filmlist --- .../filmlisten/reader/FilmListReader.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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;