From 1ec9022a5b5b4e24f14810509ac823b55c1651f6 Mon Sep 17 00:00:00 2001 From: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com> Date: Tue, 1 Sep 2026 17:27:26 +0200 Subject: [PATCH] perf(jobs): run preview pre-warm daily, time-insensitive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PreviewEnhancementProcessingJob fired hourly per account. It can't be scaled per activity — run()-time setInterval() isn't persisted, so the constructor interval governs pickup — and previews are already computed on demand when a mailbox is opened, so the background job only backfills. Run it once a day and mark it time-insensitive so it can be deferred under load. Assisted-by: ClaudeCode:claude-opus-4-8 Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com> --- .../PreviewEnhancementProcessingJob.php | 5 +- .../PreviewEnhancementProcessingJobTest.php | 56 +++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 tests/Unit/BackgroundJob/PreviewEnhancementProcessingJobTest.php diff --git a/lib/BackgroundJob/PreviewEnhancementProcessingJob.php b/lib/BackgroundJob/PreviewEnhancementProcessingJob.php index 947c805667..e34a0f9aa8 100644 --- a/lib/BackgroundJob/PreviewEnhancementProcessingJob.php +++ b/lib/BackgroundJob/PreviewEnhancementProcessingJob.php @@ -35,8 +35,9 @@ public function __construct( $this->userManager = $userManager; $this->jobList = $jobList; - $this->setInterval(3600); - $this->setTimeSensitivity(self::TIME_SENSITIVE); + // Background pre-warm only; previews are computed on demand on mailbox open, so run rarely and defer under load + $this->setInterval(24 * 3600); + $this->setTimeSensitivity(self::TIME_INSENSITIVE); } /** diff --git a/tests/Unit/BackgroundJob/PreviewEnhancementProcessingJobTest.php b/tests/Unit/BackgroundJob/PreviewEnhancementProcessingJobTest.php new file mode 100644 index 0000000000..9c62882676 --- /dev/null +++ b/tests/Unit/BackgroundJob/PreviewEnhancementProcessingJobTest.php @@ -0,0 +1,56 @@ +time = $this->createMock(ITimeFactory::class); + $this->userManager = $this->createMock(IUserManager::class); + $this->accountService = $this->createMock(AccountService::class); + $this->preprocessingService = $this->createMock(PreprocessingService::class); + $this->logger = $this->createMock(LoggerInterface::class); + $this->jobList = $this->createMock(IJobList::class); + + $this->job = new PreviewEnhancementProcessingJob( + $this->time, + $this->userManager, + $this->accountService, + $this->preprocessingService, + $this->logger, + $this->jobList, + ); + } + + public function testRunsDailyAndDeferrableUnderLoad(): void { + self::assertSame(24 * 3600, $this->job->getInterval()); + self::assertFalse($this->job->isTimeSensitive()); + } +}