65 protected static $data = array();
87 'data_type' =>
'date',
91 'data_type' =>
'integer',
95 'data_type' =>
'integer',
98 'PASSWORD_ID' => array(
99 'data_type' =>
'integer',
103 'data_type' =>
'integer',
107 'data_type' =>
'integer',
111 'data_type' =>
'integer',
115 'data_type' =>
'integer',
119 'data_type' =>
'integer',
123 'data_type' =>
'integer',
127 'data_type' =>
'integer',
131 'data_type' =>
'integer',
135 'data_type' =>
'integer',
139 'data_type' =>
'integer',
143 'data_type' =>
'integer',
147 'data_type' =>
'integer',
151 'data_type' =>
'integer',
155 'data_type' =>
'integer',
159 'data_type' =>
'integer',
163 'data_type' =>
'integer',
167 'data_type' =>
'integer',
171 'data_type' =>
'integer',
175 'data_type' =>
'integer',
179 'data_type' =>
'integer',
183 'data_type' =>
'integer',
187 'data_type' =>
'integer',
191 'data_type' =>
'integer',
195 'data_type' =>
'integer',
199 'data_type' =>
'Bitrix\Rest\StatAppTable',
200 'reference' => array(
201 '=this.APP_ID' =>
'ref.APP_ID',
205 'data_type' =>
'Bitrix\Rest\StatMethodTable',
206 'reference' => array(
207 '=this.METHOD_ID' =>
'ref.ID',
211 'data_type' =>
'\Bitrix\Rest\APAuth\PasswordTable',
212 'reference' => array(
213 '=this.PASSWORD_ID' =>
'ref.ID',
219 public static function log(\CRestServer $server)
226 if($server->getClientId())
228 static::logMethod($server->getClientId(), $server->getMethod());
230 elseif($server->getPasswordId())
232 static::logApMethod($server->getPasswordId(), $server->getMethod());
241 public static function logMethod($clientId, $methodName)
246 public static function logEvent($clientId, $eventName)
266 protected static function addApToLog($passwordID, $methodName, $methodType)
268 if (!isset(static::$dataPassword[$passwordID]))
270 static::$dataPassword[$passwordID] = array();
273 if (!isset(static::$dataPassword[$passwordID][$methodName]))
275 static::$dataPassword[$passwordID][$methodName] = 0;
278 static::$dataPassword[$passwordID][$methodName]++;
281 protected static function addToLog($clientId, $methodName, $methodType)
283 if (!isset(static::$data[$clientId]))
285 static::$data[$clientId] = array();
288 if (!isset(static::$data[$clientId][$methodName]))
290 static::$data[$clientId][$methodName] = 0;
293 static::$data[$clientId][$methodName]++;
303 $connection = Main\Application::getConnection();
304 $helper = $connection->getSqlHelper();
306 $hour = intval(date(
'G'));
308 if(count(static::$data) > 0)
310 foreach(static::$data as $clientId => $stat)
316 foreach($stat as $methodName => $count)
324 $insertFields = array(
325 'STAT_DATE' => $curDateSql,
326 'APP_ID' => $appInfo[
'ID'],
327 'METHOD_ID' => $methodId,
328 'HOUR_'.$hour => $count,
332 $updateFields = array(
333 'HOUR_'.$hour =>
new Main\DB\
SqlExpression(
'?#+?i',
'HOUR_'.$hour, $count)
336 $queries = $helper->prepareMerge(
337 static::getTableName(),
338 array(
'DATE',
'APP_ID',
'METHOD_ID'),
343 foreach($queries as $query)
345 $connection->queryExecute($query);
352 if(count(static::$dataPassword) > 0)
354 foreach(static::$dataPassword as $passwordID => $stat)
357 foreach ($stat as $methodName => $count)
365 $insertFields = array(
366 'STAT_DATE' => $curDateSql,
367 'PASSWORD_ID' => $passwordID,
368 'METHOD_ID' => $methodId,
369 'HOUR_' . $hour => $count,
373 $updateFields = array(
374 'HOUR_'.$hour =>
new Main\DB\
SqlExpression(
'?#+?i',
'HOUR_'.$hour, $count)
377 $queries = $helper->prepareMerge(
378 static::getTableName(),
379 array(
'DATE',
'APP_ID',
'METHOD_ID'),
384 foreach($queries as $query)
386 $connection->queryExecute($query);
397 static::$data = array();
405 $entity = static::getEntity();
406 $sqlTableName = static::getTableName();
408 $where = Main\Entity\Query::buildFilterSql($entity, $filter);
411 $sql =
"DELETE FROM {$sqlTableName} WHERE ".$where;
412 $entity->getConnection()->queryExecute($sql);
422 $entity = static::getEntity();
423 $sqlHelper = $entity->getConnection()->getSqlHelper();
424 $sqlTableName = static::getTableName();
426 $update = $sqlHelper->prepareUpdate($sqlTableName, $fields);
427 $where = Main\Entity\Query::buildFilterSql($entity, $filter);
428 if($where <>
'' && $update[0] <>
'')
430 $sql =
"UPDATE {$sqlTableName} SET $update[0] WHERE $where";
431 $entity->getConnection()->queryExecute($sql);
440 static::deleteByFilter(array(
441 "<STAT_DATE" => $date,
444 return "\\Bitrix\\Rest\\StatTable::cleanUpAgent();";
static isModuleInstalled($moduleName)
static getByClientId($clientId)
static register($appInfo)
static getId($methodName)
const METHOD_TYPE_ACTIVITY
const METHOD_TYPE_PLACEMENT
static addApToLog($passwordID, $methodName, $methodType)
static log(\CRestServer $server)
static logActivity($clientId)
static addToLog($clientId, $methodName, $methodType)
static deleteByFilter(array $filter)
static updateByFilter(array $filter, array $fields)
static logEvent($clientId, $eventName)
static logApMethod($passwordID, $methodName)
static logMethod($clientId, $methodName)
static logPlacement($clientId, $placementName)
static logRobot($clientId)