- Модуль: abtest
- Путь к файлу: ~/bitrix/modules/abtest/lib/adminhelper.php
- Класс: BitrixABTestAdminHelper
- Вызов: AdminHelper::getTestCapacity
static function getTestCapacity($id)
{
$cache = new CPHPCache();
if ($cache->initCache(time()-strtotime('today'), 'abtest_capacity_'.intval($id), '/abtest'))
{
$capacity = $cache->getVars();
}
else if (Loader::includeModule('conversion'))
{
if ($conversionRates = ConversionRateManager::getTypes(array('ACTIVE' => true)))
{
if ($abtest = ABTestTable::getById($id)->fetch())
{
$lid = $abtest['SITE_ID'];
$baseRate = array_slice($conversionRates, 0, 1, true);
$reportContext = new ConversionReportContext;
$reportContext->setAttribute('conversion_site', $lid);
$reportContext->setAttribute('abtest', $id);
$reportContext->setAttribute('abtest_section', 'A');
$groupAData = reset($reportContext->getRatesDeprecated($baseRate, array(), null));
$reportContext->unsetAttribute('abtest_section', 'A');
$reportContext->setAttribute('abtest_section', 'B');
$groupBData = reset($reportContext->getRatesDeprecated($baseRate, array(), null));
$capacity = array(
'A' => $groupAData['DENOMINATOR'],
'B' => $groupBData['DENOMINATOR']
);
$cache->startDataCache(strtotime('tomorrow')-time());
$cache->endDataCache($capacity);
}
}
}
return !empty($capacity) ? $capacity : array('A' => 0, 'B' => 0);
}