136 $endpoints = $data[
'ENDPOINTS'];
137 unset($data[
'ENDPOINTS']);
140 && isset($data[
'STATUS'])
146 $id = $this->saveByEntity(GroupTable::getEntity(), $id, $data);
152 $dataCounters = array();
153 GroupConnectorTable::delete(array(
'GROUP_ID' => $id));
157 foreach ($endpoints as $endpoint)
159 $connector = Connector\Manager::getConnector($endpoint);
170 $connector->setFieldValues(is_array($endpoint[
'FIELDS']) ? $endpoint[
'FIELDS'] :
null);
171 $endpoint[
'FIELDS'] =
$connector->getFieldValues();
174 foreach (array_intersect($statFields, array_keys($endpoint[
'FIELDS'])) as $field)
176 \Bitrix\Sender\Log::stat(
'segment_field', $field, $id);
180 $dataCounter = $isIncrementally
184 $groupConnector = array(
187 'ENDPOINT' => $endpoint,
188 'ADDRESS_COUNT' => $dataCounter->getSummary()
191 if(isset($endpoint[
'FILTER_ID']))
193 $groupConnector[
'FILTER_ID'] = $endpoint[
'FILTER_ID'];
196 $connectorResultDb = GroupConnectorTable::add($groupConnector);
197 if($connectorResultDb->isSuccess())
199 $dataCounters[] = $dataCounter;
207 SegmentDataBuilder::actualize($id,
true);
210 SegmentDataBuilder::checkIsSegmentPrepared($id);
386 $countByType = array();
387 foreach ($counters as $dataCounter)
389 $count += $dataCounter->getSummary();
390 $list = $dataCounter->getList();
391 foreach ($list as $typeId => $typeCount)
393 if (!isset($countByType[$typeId]))
395 $countByType[$typeId] = 0;
398 $countByType[$typeId] += $typeCount;
403 $result = GroupTable::update($segmentId, array(
'ADDRESS_COUNT' => $count));
404 if (!$result->isSuccess())
409 GroupCounterTable::deleteByGroupId($segmentId);
410 foreach ($countByType as $typeId => $typeCount)
417 GroupCounterTable::add(array(
418 'GROUP_ID' => $segmentId,
419 'TYPE_ID' => $typeId,