- Модуль: sender
- Путь к файлу: ~/bitrix/modules/sender/lib/integration/bitrix24/limitation/rating.php
- Класс: Bitrix\Sender\Integration\Bitrix24\Limitation\Rating
- Вызов: Rating::calculate
static function calculate() { $updateTimestamp = (int) self::getParam('date_update', 0); $dateToday = new Date(); if ($dateToday->getTimestamp() <= $updateTimestamp) { return; } self::setParam('date_update', $dateToday->getTimestamp()); if (!$updateTimestamp) { return; } $yesterdayData = Model\DailyCounterTable::getRowByDate(1); if (!$yesterdayData) { return; } // don't upgrade if error count more than 10% of sent $countSent = (int) $yesterdayData['SENT_CNT']; $countError = (int) $yesterdayData['ERROR_CNT']; if ($countSent > 0 && ($countError / $countSent) > 0.1) { $countSent -= $countError; } $ratio = self::getRatio(1); if ($ratio >= self::getBlockRate()) { self::block(); } elseif ($ratio >= self::getDownRate()) { self::downgrade(); } elseif ($countSent >= DailyLimit::instance()->getLimit()) { self::upgrade(); } }