193 $prefix = $this->isInclude ?
'' :
'_EXCLUDE';
194 $fieldDateUse =
"DATE_USE$prefix";
195 $fieldUseCount =
"USE_COUNT$prefix";
197 if (!isset($parameters[
'order']))
199 $parameters[
'order'] = [
202 $fieldDateUse =>
'DESC',
206 $segments = GroupTable::getList($parameters);
208 foreach ($segments as $segment)
211 'id' => $segment[
'ID'],
212 'name' => $segment[
'NAME'],
214 'last' => $segment[$fieldDateUse],
215 'freq' => (int)$segment[$fieldUseCount],
216 'case' => mb_substr($segment[
'CODE'], 0, 5) ===
'case_',
217 'hidden' => $segment[
'HIDDEN'] ===
'Y',
218 'system' => $segment[
'IS_SYSTEM'] ===
'Y',
219 'hasStatic' =>
false,
226 $ids[] = $item[
'id'];
231 $connectors = GroupConnectorTable::getList([
245 $entityConnector = \Bitrix\Sender\Connector\Manager::getConnector(
$connector[
'ENDPOINT']);
255 $duration = Dispatch\DurationCountBased::create($this->message);
256 $messageTypes = $this->message->getSupportedRecipientTypes();
259 $counters = Entity\Segment::getAddressCounters($ids);
260 foreach ($result as $index => $item)
262 if (!isset($counters[$item[
'id']]))
268 $item[
'data'][
'count'] = $counters[$item[
'id']];
269 $item[
'data'][
'hasStatic'] = $hasStatic[$item[
'id']];
272 foreach ($item[
'data'][
'count'] as $typeId => $count)
274 if (isset($item[
'data'][
'duration']) && $item[
'data'][
'duration'])
279 if (!$duration || !$this->message)
284 if (!in_array($typeId, $messageTypes))
289 $item[
'data'][
'duration'] = $duration->getIntervalDefault($count);
292 $result[$index] = $item;