diff --git a/src/main/java/mediathek/config/Daten.java b/src/main/java/mediathek/config/Daten.java index aa22b4d59f..ede766373c 100644 --- a/src/main/java/mediathek/config/Daten.java +++ b/src/main/java/mediathek/config/Daten.java @@ -1,5 +1,7 @@ package mediathek.config; +import ca.odell.glazedlists.BasicEventList; +import ca.odell.glazedlists.EventList; import com.google.common.util.concurrent.*; import mediathek.Main; import mediathek.SplashScreen; @@ -10,6 +12,7 @@ import mediathek.daten.*; import mediathek.daten.blacklist.ListeBlacklist; import mediathek.filmlisten.FilmeLaden; +import mediathek.filmlisten.reader.FilmListReader; import mediathek.javafx.bookmark.BookmarkDataList; import mediathek.tool.ReplaceList; import mediathek.tool.notification.INotificationCenter; @@ -36,6 +39,8 @@ import java.util.concurrent.atomic.AtomicBoolean; public class Daten { + private final EventList statisticsEventList = new BasicEventList<>(); + public EventList getFilmListDuplicateStatisticsList() { return statisticsEventList; } public static final MVColor mVColor = new MVColor(); // verwendete Farben /** * Prevent the unnecessary writing of a filmlist on startup when reading is enough diff --git a/src/main/java/mediathek/filmlisten/reader/FilmListReader.java b/src/main/java/mediathek/filmlisten/reader/FilmListReader.java index 19ff5c041d..906886549d 100644 --- a/src/main/java/mediathek/filmlisten/reader/FilmListReader.java +++ b/src/main/java/mediathek/filmlisten/reader/FilmListReader.java @@ -6,6 +6,7 @@ import com.google.common.base.Stopwatch; import com.google.common.collect.Sets; import mediathek.config.Config; +import mediathek.config.Daten; import mediathek.config.Konstanten; import mediathek.controller.SenderFilmlistLoadApprover; import mediathek.daten.Country; @@ -44,7 +45,9 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; -import java.util.*; +import java.util.Arrays; +import java.util.List; +import java.util.Set; import java.util.stream.Collectors; public class FilmListReader implements AutoCloseable { @@ -373,22 +376,24 @@ private void readData(JsonParser jp, ListeFilme listeFilme) throws IOException { printDuplicateStatistics(listeFilme); } + public record DuplicateStatistics(String sender, long count) {} + private void printDuplicateStatistics(@NotNull ListeFilme listeFilme) { Stopwatch watch = Stopwatch.createStarted(); final var duplicates = listeFilme.parallelStream() .filter(DatenFilm::isDuplicate) .toList(); final var senders = duplicates.parallelStream().map(DatenFilm::getSender).distinct().toList(); - final Map statistics = new HashMap<>(); + var statisticsEventList = Daten.getInstance().getFilmListDuplicateStatisticsList(); for (var sender: senders) { final var dupes = duplicates.parallelStream().filter(f -> f.getSender().equals(sender)).count(); - statistics.put(sender, dupes); + statisticsEventList.add(new DuplicateStatistics(sender, dupes)); } watch.stop(); - logger.trace(statistics.toString()); + logger.trace(statisticsEventList.toString()); long dupes = 0; - for (var key: statistics.keySet()) { - dupes += statistics.get(key); + for (var item : statisticsEventList) { + dupes += item.count; } logger.trace("Duplicate stream filter took: {}", watch); logger.trace("Number of duplicates: {}", duplicates.size());