Skip to content

Commit

Permalink
#336 refactored initialize podcast episodes
Browse files Browse the repository at this point in the history
  • Loading branch information
kagemomiji committed Dec 21, 2023
1 parent 5233db4 commit 1d5ed32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public Optional<PodcastEpisode> findByChannelAndTitleAndPublishDate(PodcastChann

public List<PodcastEpisode> findByChannel(PodcastChannel channel);

public List<PodcastEpisode> findByChannelAndStatus(PodcastChannel channel, PodcastStatus status);

public List<PodcastEpisode> findByStatusAndPublishDateNotNullAndMediaFilePresentTrueOrderByPublishDateDesc(
PodcastStatus status);
PodcastStatus status);

}
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,9 @@ public PodcastPersistenceService(
*/
public void cleanDownloadingEpisodes() {
podcastChannelRepository.findAll()
.parallelStream()
.map(PodcastChannel::getId)
.map(this::getEpisodes)
.flatMap(List::parallelStream)
.filter(e -> e.getStatus() == PodcastStatus.DOWNLOADING)
.stream()
.flatMap(c -> podcastEpisodeRepository.findByChannelAndStatus(c, PodcastStatus.DOWNLOADING).stream())
.filter(filterAllowed)
.forEach(e -> {
deleteEpisode(e, false);
LOG.info("Deleted Podcast episode '{}' since download was interrupted.", e.getTitle());
Expand Down

0 comments on commit 1d5ed32

Please sign in to comment.