Skip to content

Commit

Permalink
- always perform duplicate check when reading filmlist
Browse files Browse the repository at this point in the history
  • Loading branch information
derreisende77 committed Oct 21, 2024
1 parent 03b9849 commit 5860b7e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/java/mediathek/filmlisten/reader/FilmListReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<String, Long> 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;
Expand Down

0 comments on commit 5860b7e

Please sign in to comment.