Compare commits

...

4 Commits

Author SHA1 Message Date
7c8fa0c439 fix: migration 2025-07-08 18:47:10 -05:00
97aa8d8982 fix: migrations 2025-07-08 16:43:37 -05:00
a88720fe7e fix: monitor not increasing count after error 2025-07-08 16:26:07 -05:00
8a12303470 fix: download season logging 2025-07-08 16:22:16 -05:00
3 changed files with 11 additions and 23 deletions

View File

@@ -20,12 +20,6 @@ final class Version20250708033046 extends AbstractMigration
public function up(Schema $schema): void public function up(Schema $schema): void
{ {
// this up() migration is auto-generated, please modify it to your needs // this up() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL'
DROP TABLE sessions
SQL);
$this->addSql(<<<'SQL'
ALTER TABLE download CHANGE created_at created_at DATETIME NOT NULL, CHANGE updated_at updated_at DATETIME NOT NULL
SQL);
$this->addSql(<<<'SQL' $this->addSql(<<<'SQL'
ALTER TABLE monitor ADD only_future TINYINT(1) NOT NULL DEFAULT 1 ALTER TABLE monitor ADD only_future TINYINT(1) NOT NULL DEFAULT 1
SQL); SQL);
@@ -34,14 +28,8 @@ final class Version20250708033046 extends AbstractMigration
public function down(Schema $schema): void public function down(Schema $schema): void
{ {
// this down() migration is auto-generated, please modify it to your needs // this down() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL'
CREATE TABLE sessions (sess_id VARBINARY(128) NOT NULL, sess_data LONGBLOB NOT NULL, sess_lifetime INT UNSIGNED NOT NULL, sess_time INT UNSIGNED NOT NULL, INDEX sess_lifetime_idx (sess_lifetime), PRIMARY KEY(sess_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_bin` ENGINE = InnoDB COMMENT = ''
SQL);
$this->addSql(<<<'SQL' $this->addSql(<<<'SQL'
ALTER TABLE monitor DROP only_future ALTER TABLE monitor DROP only_future
SQL); SQL);
$this->addSql(<<<'SQL'
ALTER TABLE download CHANGE created_at created_at DATETIME DEFAULT NULL, CHANGE updated_at updated_at DATETIME DEFAULT NULL
SQL);
} }
} }

View File

@@ -60,7 +60,7 @@ readonly class DownloadSeasonHandler implements HandlerInterface
) )
); );
$this->logger->info('> [DownloadTvSeasonHandler] ...Found ' . count($results->results) . ' total download options, beginning evaluation'); $this->logger->info('> [DownloadTvSeasonHandler] ......Found ' . count($results->results) . ' total download options, beginning evaluation');
$userPreferences = UserPreferencesFactory::createFromUser( $userPreferences = UserPreferencesFactory::createFromUser(
$this->userRepository->findOneBy(['id' => $command->userId]) $this->userRepository->findOneBy(['id' => $command->userId])
@@ -69,7 +69,8 @@ readonly class DownloadSeasonHandler implements HandlerInterface
$result = $this->downloadOptionEvaluator->evaluateOptions($results->results, $userPreferences); $result = $this->downloadOptionEvaluator->evaluateOptions($results->results, $userPreferences);
if (null !== $result) { if (null !== $result) {
$this->logger->info('> [DownloadTvSeasonHandler] ......Found 1 matching result: dispatching DownloadMediaCommand for "' . $result->title . '"'); $this->logger->info('> [DownloadTvSeasonHandler] ......Found 1 matching result');
$this->logger->info('> [DownloadTvSeasonHandler] ......Dispatching DownloadMediaCommand for "' . $series->title . '" season ' . $command->season . ' episode ' . $episode['episode_number']);
$downloadCommand = new DownloadMediaCommand( $downloadCommand = new DownloadMediaCommand(
$result->url, $result->url,
$series->title, $series->title,

View File

@@ -3,10 +3,10 @@
namespace App\Monitor\Action\Handler; namespace App\Monitor\Action\Handler;
use App\Download\Action\Command\DownloadMediaCommand; use App\Download\Action\Command\DownloadMediaCommand;
use App\Download\DownloadOptionEvaluator;
use App\Monitor\Action\Command\MonitorMovieCommand; use App\Monitor\Action\Command\MonitorMovieCommand;
use App\Monitor\Action\Result\MonitorTvEpisodeResult; use App\Monitor\Action\Result\MonitorTvEpisodeResult;
use App\Monitor\Framework\Repository\MonitorRepository; use App\Monitor\Framework\Repository\MonitorRepository;
use App\Monitor\Service\MonitorOptionEvaluator;
use App\Tmdb\Tmdb; use App\Tmdb\Tmdb;
use App\Torrentio\Action\Command\GetTvShowOptionsCommand; use App\Torrentio\Action\Command\GetTvShowOptionsCommand;
use App\Torrentio\Action\Handler\GetTvShowOptionsHandler; use App\Torrentio\Action\Handler\GetTvShowOptionsHandler;
@@ -25,7 +25,7 @@ readonly class MonitorTvEpisodeHandler implements HandlerInterface
{ {
public function __construct( public function __construct(
private GetTvShowOptionsHandler $getTvShowOptionsHandler, private GetTvShowOptionsHandler $getTvShowOptionsHandler,
private MonitorOptionEvaluator $monitorOptionEvaluator, private DownloadOptionEvaluator $downloadOptionEvaluator,
private EntityManagerInterface $entityManager, private EntityManagerInterface $entityManager,
private MessageBusInterface $bus, private MessageBusInterface $bus,
private LoggerInterface $logger, private LoggerInterface $logger,
@@ -65,10 +65,10 @@ readonly class MonitorTvEpisodeHandler implements HandlerInterface
$this->logger->info('> [MonitorTvEpisodeHandler] ...Found ' . count($results->results) . ' total download options, beginning evaluation'); $this->logger->info('> [MonitorTvEpisodeHandler] ...Found ' . count($results->results) . ' total download options, beginning evaluation');
$result = $this->monitorOptionEvaluator->evaluateOptions($monitor, $results->results); $result = $this->downloadOptionEvaluator->evaluateOptions($results->results, UserPreferencesFactory::createFromUser($monitor->getUser()));
if (null !== $result) { if (null !== $result) {
$this->logger->info('> [MonitorTvEpisodeHandler] ...Found 1 matching result found: dispatching DownloadMediaCommand for "' . $result->title . '"', ['filter' => UserPreferencesFactory::createFromUser($monitor->getUser())]); $this->logger->info('> [MonitorTvEpisodeHandler] ...Found 1 matching result found: dispatching DownloadMediaCommand for "' . $result->title . '"');
$this->bus->dispatch(new DownloadMediaCommand( $this->bus->dispatch(new DownloadMediaCommand(
$result->url, $result->url,
$monitor->getTitle(), $monitor->getTitle(),
@@ -83,17 +83,16 @@ readonly class MonitorTvEpisodeHandler implements HandlerInterface
$this->logger->info('> [MonitorTvEpisodeHandler] ...Found 0 matching results found, monitor will run at next interval'); $this->logger->info('> [MonitorTvEpisodeHandler] ...Found 0 matching results found, monitor will run at next interval');
$monitor->setStatus('Active'); $monitor->setStatus('Active');
} }
$monitor->setLastSearch(new DateTimeImmutable());
$monitor->setSearchCount($monitor->getSearchCount() + 1);
$this->entityManager->flush();
} catch (\Throwable $exception) { } catch (\Throwable $exception) {
$this->logger->error('> [MonitorTvEpisodeHandler] ...Exception thrown: ' . $exception->getMessage()); $this->logger->error('> [MonitorTvEpisodeHandler] ...Exception thrown: ' . $exception->getMessage());
$this->logger->error($exception->getMessage()); $this->logger->error($exception->getMessage());
$monitor->setStatus('Active'); $monitor->setStatus('Active');
$this->monitorRepository->getEntityManager()->flush();
} }
$monitor->setLastSearch(new DateTimeImmutable());
$monitor->setSearchCount($monitor->getSearchCount() + 1);
$this->monitorRepository->getEntityManager()->flush();
return new MonitorTvEpisodeResult( return new MonitorTvEpisodeResult(
status: 'OK', status: 'OK',
result: [ result: [