23 private const LIMIT = 100;
24 protected static $moduleId = Common::CALENDAR_MODULE_ID;
29 $offset = (int)(
$option[
'offset'] ?? 0);
33 $mapperFactory = ServiceLocator::getInstance()->get(
'calendar.service.mappers.factory');
35 $calendarEvent = $mapperFactory->getEvent()->getById($eventId);
39 return self::FINISH_EXECUTION;
42 $userIds = $this->getAffectedUserIds($calendarEvent, $offset);
46 return self::FINISH_EXECUTION;
50 ->upCounter(event: $calendarEvent, userIds: $userIds)
51 ->setOptions(options:
$option, offset: $offset)
54 return self::CONTINUE_EXECUTION;
57 private function getAffectedUserIds(CalendarEvent
$event,
int $offset):
array
60 $eventCategory =
$event->getEventOption()->getCategory();
64 $categoryId = $eventCategory->getId();
66 $userIds = $eventCategory->getClosed()
67 ? $this->getChannelUsers(categoryId: $categoryId, offset: $offset)
68 : $this->getAllUsers(offset: $offset)
72 $usersWhoBannedTheCategory = $categoryBanProvider->getUsersWhoBannedTheCategory($userIds, $categoryId);
74 return array_filter($userIds,
static fn(
int $userId) => !$usersWhoBannedTheCategory[
$userId]);
78 (
new Logger())->log($exception);
84 private function upCounter(CalendarEvent
$event,
array $userIds): self
86 (
new Processor\OpenEvent())->upCounter(userIds: $userIds, event:
$event);
91 private function setOptions(
array &
$options,
int $offset): self
93 $options[
'offset'] = $offset + $this->getLimit();
98 private function getAllUsers(
int $offset):
array
102 $query = UserTable::query()
104 ->where(
'ACTIVE',
'Y')
105 ->where(
'IS_REAL_USER',
'Y')
106 ->where(
'UF_DEPARTMENT',
'!=',
false)
108 ->setLimit($this->getLimit())
112 while ($item =
$query->fetch())
114 $userIds[] = (int)$item[
'ID'];
120 private function getChannelUsers(
int $categoryId,
int $offset):
array
125 ->setSelect([
'USER_ID'])
126 ->where(
'CATEGORY_ID',
'=', $categoryId)
127 ->addOrder(
'USER_ID')
128 ->setLimit($this->getLimit())
133 while ($item =
$query->fetch())
135 $userIds[] = (int)$item[
'USER_ID'];
141 private function getLimit(): int
143 $limit = \COption::GetOptionString(
'calendar',
'calendarCounterStepperLimit',
'');