From d2f006892cacca3f4f617b80d09f436f0661f051 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Fri, 21 Jul 2023 13:25:29 +0300 Subject: [PATCH] scheduler free busy increase max range, non-working always --- .../Espo/Modules/Crm/Tools/Calendar/Service.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/application/Espo/Modules/Crm/Tools/Calendar/Service.php b/application/Espo/Modules/Crm/Tools/Calendar/Service.php index ccbdad08dc..5370883a4e 100644 --- a/application/Espo/Modules/Crm/Tools/Calendar/Service.php +++ b/application/Espo/Modules/Crm/Tools/Calendar/Service.php @@ -61,7 +61,7 @@ use RuntimeException; class Service { - private const BUSY_RANGES_MAX_RANGE_DAYS = 10; + private const BUSY_RANGES_MAX_RANGE_DAYS = 20; /** @var array */ private array $entityTypeCanceledStatusListCacheMap = []; @@ -923,11 +923,13 @@ class Service } } + $toReturn = true; + try { $diff = $to->getDateTime()->diff($from->getDateTime(), true); if ($diff->days > $this->config->get('busyRangesMaxRange', self::BUSY_RANGES_MAX_RANGE_DAYS)) { - return []; + $toReturn = false; } } catch (Exception) { @@ -952,7 +954,9 @@ class Service ->withScopeList($scopeList); foreach ($userIdList as $userId) { - $user = $this->entityManager->getEntityById(User::ENTITY_TYPE, $userId); + $user = $this->entityManager + ->getRDBRepositoryByClass(User::class) + ->getById($userId); if (!$user) { continue; @@ -971,7 +975,9 @@ class Service []; try { - $busyRangeList = $this->fetchBusyRanges($userId, $fetchParams, $ignoreList); + $busyRangeList = $toReturn ? + $this->fetchBusyRanges($userId, $fetchParams, $ignoreList) : + []; } catch (Exception $e) { if ($e instanceof Forbidden) {