Do not add progress events to the queue if progress task is disabled.

This commit is contained in:
abdulmohsen
2024-08-17 22:28:33 +03:00
parent c2609d1720
commit 0a1fe83470
3 changed files with 5 additions and 4 deletions

View File

@@ -208,7 +208,8 @@ final class Webhooks
$this->cache->set('requests', $items, new DateInterval('P3D'));
if (false === $metadataOnly && true === $entity->hasPlayProgress() && !$entity->isWatched()) {
$pEnabled = (bool)env('WS_CRON_PROGRESS', false);
if ($pEnabled && false === $metadataOnly && true === $entity->hasPlayProgress() && !$entity->isWatched()) {
$progress = $this->cache->get('progress', []);
$progress[str_replace($itemId, ':tainted@', ':untainted@')] = $entity;
$this->cache->set('progress', $progress, new DateInterval('P3D'));
@@ -223,7 +224,7 @@ final class Webhooks
'type' => $entity->type,
'played' => $entity->isWatched() ? 'Yes' : 'No',
'queue_id' => $itemId,
'progress' => $entity->hasPlayProgress() ? $entity->getPlayProgress() : null,
'progress' => $pEnabled && $entity->hasPlayProgress() ? $entity->getPlayProgress() : null,
]
]
);

View File

@@ -740,7 +740,7 @@ final class DirectMapper implements iImport
*/
public function commit(): array
{
if (count($this->progressItems) >= 1) {
if (true === (bool)env('WS_CRON_PROGRESS', false) && count($this->progressItems) >= 1) {
try {
$progress = $this->cache->get('progress', []);
foreach ($this->progressItems as $itemId => $entity) {

View File

@@ -543,7 +543,7 @@ final class MemoryMapper implements iImport
public function commit(): mixed
{
if (true !== $this->inDryRunMode()) {
if (count($this->progressItems) >= 1) {
if (true === (bool)env('WS_CRON_PROGRESS', false) && count($this->progressItems) >= 1) {
try {
$progress = $this->cache->get('progress', []);
foreach ($this->progressItems as $itemId => $entity) {