protected function setBayesian(array $data)
    {
        $rating = $this->getBayesian($data);

        if (empty($rating['bayesian_rating'])) {
            $this->db->delete('rating', array('product_id' => $data['product_id']));
            return array();
        }

        $sql = 'INSERT INTO rating
                SET rating=:rating, votes=:votes, product_id=:product_id
                ON DUPLICATE KEY UPDATE rating=:rating, votes=:votes';

        $params = array(
            'product_id' => $data['product_id'],
            'votes' => $rating['this_num_votes'],
            'rating' => $rating['bayesian_rating']
        );

        $this->db->run($sql, $params);
        return $rating;
    }