• Модуль: rest
  • Путь к файлу: ~/bitrix/modules/rest/lib/log.php
  • Класс: BitrixRestLogTable
  • Вызов: LogTable::cleanUpAgent
static function cleanUpAgent()
{
	$entity = static::getEntity();
	$sqlTableName = static::getTableName();
	$connection = $entity->getConnection();

	$lastIdQuery = $connection->query("
		SELECT max(ID) MID
		from {$sqlTableName}
	");
	$lastId = $lastIdQuery->fetch();
	if ($lastId && $lastId['MID'])
	{
		$date = new MainTypeDateTime();
		$date->add("-7D");

		$lastTimeQuery = $connection->query("
			SELECT TIMESTAMP_X
			from {$sqlTableName}
			WHERE ID = $lastId[MID]
		");
		$lastTime = $lastTimeQuery->fetch();
		if ($lastTime && $lastTime['TIMESTAMP_X'] < $date)
		{
			static::clearAll();
		}
	}

	return "\Bitrix\Rest\LogTable::cleanUpAgent();";
}