- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/classes/general/ratings.php
- Класс: CAllRatings
- Вызов: CAllRatings::GetRatingUserPropEx
static function GetRatingUserPropEx($ratingId, $entityId)
{
global $DB, $CACHE_MANAGER;
$err_mess = (CRatings::err_mess())."
Function: GetRatingUserPropEx
Line: ";
$ratingId = (int)$ratingId;
$entityId = (int)$entityId;
$arDefaultResult = array(
"RATING_ID" => $ratingId,
"ENTITY_ID" => $entityId,
"BONUS" => 0,
"VOTE_WEIGHT" => 0,
"VOTE_COUNT" => 0
);
if ($ratingId <= 0 || $entityId <= 0)
return $arDefaultResult;
$bucket_size = (int)CACHED_b_rating_bucket_size;
if($bucket_size <= 0)
$bucket_size = 100;
$bucket = (int)($entityId / $bucket_size);
$arResult = $CACHE_MANAGER->Read(CACHED_b_rating, $cache_id="b_rvu_".$ratingId.$bucket, "b_rating_user");
if($arResult)
{
$arResult = $CACHE_MANAGER->Get($cache_id);
}
if (!$arResult)
{
$sql_str = "
SELECT RATING_ID, ENTITY_ID, BONUS, VOTE_WEIGHT, VOTE_COUNT
FROM b_rating_user
WHERE RATING_ID = '".$ratingId."'
and ENTITY_ID between ".($bucket*$bucket_size)." AND ".(($bucket+1)*$bucket_size-1)."
";
$res = $DB->Query($sql_str, false, $err_mess.__LINE__);
while($arRes = $res->Fetch())
$arResult[$arRes["ENTITY_ID"]] = $arRes;
$CACHE_MANAGER->Set($cache_id, $arResult);
}
return $arResult[$entityId] ?? $arDefaultResult;
}