Skip to content

Commit

Permalink
Small performance improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
leepeuker committed Dec 28, 2022
1 parent afad6d4 commit 03a09e9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Service/Trakt/ImportWatchedMovies.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,19 @@ private function isWatchedCacheUpToDate(int $userId, Api\Trakt\ValueObject\User\

private function removeWatchesNoLongerExistingInTrakt(int $userId, Api\Trakt\ValueObject\User\Movie\Watched\DtoList $traktWatchedMovies, bool $overwriteExistingData) : void
{
if ($overwriteExistingData === false) {
$this->logger->debug('Trakt history import: Skipping removing outdated watch dates, no overwrite set');

exit;
}

foreach ($this->traktApi->fetchUniqueCachedTraktIds($userId) as $cachedTraktId) {
if ($traktWatchedMovies->containsTraktId($cachedTraktId) === true) {
continue;
}

$this->traktApi->removeWatchCacheByTraktId($userId, $cachedTraktId);

if ($overwriteExistingData === false) {
continue;
}

$this->movieApi->deleteHistoryForUserByTraktId($userId, $cachedTraktId);
$this->logger->info('Trakt history import: Removed outdated watch dates for movie with trakt id: ' . $cachedTraktId);
}
Expand Down

0 comments on commit 03a09e9

Please sign in to comment.