redis->hIncrBy($key, 'total_score', $score); $this->redis->hIncrBy($key, 'total_count', 1); } /** * @param int $chefId * @return float|int * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function getChefEvaluation(int $chefId): float|int { $key = ApiRedisKey::chefEvaluationKey($chefId); $totalScore = $this->redis->hGet($key, 'total_score'); $totalCount = $this->redis->hGet($key, 'total_count'); if (empty($totalScore) || empty($totalCount)) return 0; $avgScore = $totalScore / $totalCount; if ($avgScore < 4) { $normalized = $avgScore / 4; $avgScore = 4 + 1 - exp(-2 * $normalized); } return round($avgScore,1); } }