5use Bitrix\Main\DB\SqlQueryException;
6use Bitrix\Main\SystemException;
69 return 'b_rest_usage_stat';
81 'data_type' =>
'date',
85 'data_type' =>
'integer',
89 'data_type' =>
'boolean',
96 'data_type' =>
'integer',
100 'data_type' =>
'integer',
104 'data_type' =>
'integer',
108 'data_type' =>
'integer',
112 'data_type' =>
'integer',
116 'data_type' =>
'integer',
120 'data_type' =>
'integer',
124 'data_type' =>
'integer',
128 'data_type' =>
'integer',
132 'data_type' =>
'integer',
136 'data_type' =>
'integer',
140 'data_type' =>
'integer',
144 'data_type' =>
'integer',
148 'data_type' =>
'integer',
152 'data_type' =>
'integer',
156 'data_type' =>
'integer',
160 'data_type' =>
'integer',
164 'data_type' =>
'integer',
168 'data_type' =>
'integer',
172 'data_type' =>
'integer',
176 'data_type' =>
'integer',
180 'data_type' =>
'integer',
184 'data_type' =>
'integer',
188 'data_type' =>
'integer',
192 'data_type' =>
'Bitrix\Rest\UsageEntityTable',
193 'reference' =>
array(
194 '=this.ENTITY_ID' =>
'ref.ID',
200 public static function log(\CRestServer $server)
204 && !defined(
'REST_FORCE_USAGE_STAT')
200 public static function log(\CRestServer $server) {
…}
282 static::incrementByCount(
299 static::incrementByCount(
310 static::incrementByCount(
351 $entityKey = static::getEntityKey($entityType,
$entityId, $subEntityType, $subEntityName);
352 if (!isset(static::$data[$entityKey]))
354 static::$data[$entityKey] = 0;
356 static::$data[$entityKey] +=
$count;
361 $entityKey = static::getEntityKey($entityType,
$entityId, $subEntityType, $subEntityName);
362 if (!isset(static::$data[$entityKey]))
364 static::$data[$entityKey] = 0;
366 static::$data[$entityKey]++;
371 return $entityType .
"|" .
$entityId .
"|" . $subEntityType .
"|" . $subEntityName;
378 && !defined(
'REST_FORCE_USAGE_STAT')
387 $hour = intval(date(
'G'));
390 ksort(static::$data);
391 foreach (static::$data as $entityKey =>
$count)
393 list($entityType,
$entityId, $subEntityType, $subEntityName) = explode(
"|", $entityKey, 4);
406 'STAT_DATE' => $curDateSql,
407 'ENTITY_ID' => $statId,
414 $queries = $helper->prepareMerge(static::getTableName(), [
417 ], $insertFields, $updateFields);
419 foreach ($queries as
$query)
431 static::$data =
array();
441 $sqlHelper =
$entity->getConnection()->getSqlHelper();
442 $sqlTableName = static::getTableName();
444 $update = $sqlHelper->prepareUpdate($sqlTableName,
$fields);
446 if ($where <>
'' && $update[0] <>
'')
448 $sql =
"UPDATE {$sqlTableName} SET $update[0] WHERE $where";
449 $entity->getConnection()->queryExecute($sql);
459 $sqlTableName = static::getTableName();
464 $sql =
"DELETE FROM {$sqlTableName} WHERE ".$where;
465 $entity->getConnection()->queryExecute($sql);
474 static::deleteByFilter(
array(
475 "<STAT_DATE" => $date,
479 return "\\Bitrix\\Rest\\UsageStatTable::cleanUpAgent();";
486 $sqlTableName = static::getTableName();
489 SELECT MIN(STAT_DATE) STAT_DATE_MIN
492 AND (STAT_DATE < ".$helper->getCurrentDateFunction().
")
496 if($date && $date[
"STAT_DATE_MIN"])
498 if (static::sendDateStat($date[
"STAT_DATE_MIN"]))
500 static::updateByFilter(
array(
"=STAT_DATE" => $date[
"STAT_DATE_MIN"]),
array(
"IS_SENT" =>
"Y"));
503 return "\\Bitrix\\Rest\\UsageStatTable::sendAgent();";
510 $statList = static::getList(
array(
512 "ENTITY_ID" =>
"ENTITY_ID",
513 "ENTITY_TYPE" =>
"ENTITY.ENTITY_TYPE",
514 "ENTITY_CODE" =>
"ENTITY.ENTITY_CODE",
515 "SUB_ENTITY_TYPE" =>
"ENTITY.SUB_ENTITY_TYPE",
516 "SUB_ENTITY_NAME" =>
"ENTITY.SUB_ENTITY_NAME",
544 "=STAT_DATE" => $date,
549 while ($dayStat = $statList->fetch())
551 if ($dayStat[
"STAT_DATE"])
553 $dayStat[
"STAT_DATE"] = $dayStat[
"STAT_DATE"]->format(
"Y-m-d");
554 $dayStat[
'HOUR_TOTAL'] = 0;
555 for (
$i = 0;
$i < 24;
$i++)
557 $dayStat[
'HOUR_TOTAL'] += (int)$dayStat[
'HOUR_' .
$i];
558 unset($dayStat[
'HOUR_' .
$i]);
static getConnection($name="")
static register($entityType, $entityId, $subEntityType, $subEntityName)
const ENTITY_TYPE_WEBHOOK
const SUB_ENTITY_TYPE_ROBOT
const SUB_ENTITY_TYPE_BI_SUPERSET
const SUB_ENTITY_TYPE_CONFIGURATION
const SUB_ENTITY_TYPE_LANDING_KNOWLEDGE
const SUB_ENTITY_TYPE_METHOD
const SUB_ENTITY_TYPE_PLACEMENT
const SUB_ENTITY_TYPE_BIZ_PROC
const SUB_ENTITY_TYPE_SEND_MESSAGE
const ENTITY_TYPE_APPLICATION
const SUB_ENTITY_TYPE_EVENT
const SUB_ENTITY_TYPE_LANDING
const SUB_ENTITY_TYPE_LANDING_WIDGET
const SUB_ENTITY_TYPE_ACTIVITY
static getEntityKey($entityType, $entityId, $subEntityType, $subEntityName)
static logBizProc($clientId, string $clientCode)
static logHookMethod($passwordID, $methodName)
static logAI(string $clientId, string $type)
static logLanding($clientId, $type, $count=1)
static logActivity($clientId, $clientCode)
static log(\CRestServer $server)
static deleteByFilter(array $filter)
static updateByFilter(array $filter, array $fields)
static logLandingWidget(string $clientId, string $type)
static logMessage($clientId, $messageType)
static logBISuperset(string $clientId, string $type)
static logEvent($clientId, $eventName)
static sendDateStat($date)
static increment($entityType, $entityId, $subEntityType, $subEntityName)
static logConfiguration($clientId, $clientCode)
static logLandingKnowledge($clientId, string $type, int $count=1)
static logUserInterface($clientId, string $type, int $count=1)
static incrementByCount($entityType, $entityId, $subEntityType, $subEntityName, int $count)
static logMethod($clientId, $methodName)
static logPlacement($clientId, $placementName)
static logRobot($clientId, $clientCode)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)