Update rating_average and rating_count from rating data.
Note: Does not store the change!

@return bool False if no rating data was returned so no updates could be done
19905
function updateFromRatingData()
    {
        $custom = array( array( 'operation' => 'count( id )',
                                'name'      => 'rating_count' ) ,
                         array( 'operation' => 'avg( rating )',
                                'name'      => 'rating_average' ));
        $cond = array( 'contentobject_id' => $this->attribute('contentobject_id'),
                       'contentobject_attribute_id' => $this->attribute('contentobject_attribute_id') );
        $data = self::fetchObjectList( ezsrRatingDataObject::definition(), array(), $cond, null, null, false, false, $custom );
        if ( isset( $data[0]['rating_average'] ) )
        {
            $this->setAttribute( 'rating_average', $data[0]['rating_average'] );
            $this->setAttribute( 'rating_count', $data[0]['rating_count'] );
            return true;
        }
        return false;
    }
690529
protected function validateEditReview()
    {
        $this->setSubmitted('review');
        $this->setSubmittedBool('status');
        $this->setSubmitted('update', $this->data_review);

        $this->validateComponent('review');

        return !$this->hasErrors();
    }
318304
public function updateViews()
    {
        //preventing edit for anyone except malladmin
        if (\OxidEsales\Eshop\Core\Registry::getSession()->getVariable("malladmin")) {
            $oMetaData = oxNew(\OxidEsales\Eshop\Core\DbMetaDataHandler::class);
            $this->_aViewData["blViewSuccess"] = $oMetaData->updateViews();
        }
    }
1315712
def __update_rating(uid, rating):
        '''
        
        '''
        entry = TabPost.update(
            rating=rating
        ).where(TabPost.uid == uid)
        entry.execute()
323033
private function isRatingWithoutReview(Rating $rating, ArrayCollection $reviews)
    {
        $withoutReview = true;

        foreach ($reviews as $review) {
            if ($this->isReviewRating($review, $rating)) {
                $withoutReview = false;
                break;
            }
        }

        return $withoutReview;
    }
287275
private function isReviewRating(Review $review, Rating $rating)
    {
        return $rating->getType() === $review->getType()
            && $rating->getObjectId() === $review->getObjectId()
            && $rating->getRating() === $review->getRating()
            && $rating->getUserId() === $review->getUserId();
    }
398049
private function updateLevel()
    {
        if (null === $this->output || OutputInterface::VERBOSITY_QUIET === $verbosity = $this->output->getVerbosity()) {
            return false;
        }

        if (isset($this->verbosityLevelMap[$verbosity])) {
            $this->setLevel($this->verbosityLevelMap[$verbosity]);
        } else {
            $this->setLevel(Logger::DEBUG);
        }

        return true;
    }
1335675
public function actionUpdate()
    {
        if (!$model = $this->findModel()) {
            Yii::$app->session->setFlash("error", Yii::t('modules/user', "You are not logged in."));
            $this->goHome();
        }
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            Yii::$app->session->setFlash("success", Yii::t('modules/user', "Changes has been saved."));
            return $this->refresh();
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    }
71994
def update_rating(self, postid):
        '''
        
        '''
        post_data = self.get_post_data()
        rating = float(post_data['rating'])
        postinfo = MPost.get_by_uid(postid)
        if postinfo and self.userinfo:
            MRating.update(postinfo.uid, self.userinfo.uid, rating=rating)
            self.update_post(postid)
        else:
            return False
656950
public function update()
    {
        if ($this->newVersionAvailable === false
        || (!is_bool($this->newVersionAvailable) && !$this->hasUpdate())) {
            return false;
        }
        $this->backupPhar();
        $this->downloadPhar();
        $this->replacePhar();
        return true;
    }
965137
public function actionVote()
    {
        $star_rating_module = Yii::$app->getModule('star-rating');
        $response = [
            'status' => 500,
            'message' => $star_rating_module::t('Server problem')
        ];

        try
        {
            $cookies = Yii::$app->request->cookies;
            if(Yii::$app->user->isGuest)
            {
                if (!$cookies || !$cookies->getValue('visitor'))
                {
                    $cookies = Yii::$app->response->cookies;
                    $cookies->add(new Cookie([
                        'name' => 'visitor',
                        'value' => md5(time() . rand(1, 100)),
                        'expire' => (time() + (3600)),
                    ]));
                }
            }
            $item_id = isset($_POST['item_id']) ? $_POST['item_id'] : 0;
            $service_id = isset($_POST['service_id']) ? $_POST['service_id'] : 0;
            $rating = isset($_POST['rating']) ? $_POST['rating'] : 0;
            $user_id = Yii::$app->user->isGuest ? 0 : (int) Yii::$app->user->id;
            $ip = Yii::$app->request->userIP;
            $visitor_cookie = $cookies->getValue('visitor');

            if(Yii::$app->user->isGuest)
            {
                $rate = Rating::find()
                    ->where(['item_id' => $item_id, 'service_id' => $service_id, 'cookie' => $visitor_cookie])
                    ->one();
            }
            else
            {
                $rate = Rating::find()
                    ->where(['item_id' => $item_id, 'service_id' => $service_id, 'user_id' => $user_id ])
                    ->one();
            }


            if(!$rate)
            {
                $model = new Rating();
                $model->service_id = $service_id;
                $model->item_id = $item_id;
                $model->user_id = $user_id;
                $model->rating = $rating;
                $model->ip = $ip;
                $model->cookie = $visitor_cookie;

                if($model->save())
                    $response = [
                        'status' => 200,
                        'message' => $star_rating_module::t('Successful')
                    ];
                else
                    $response = [
                        'status' => 400,
                        'message' => $star_rating_module::t('Failed to save')
                    ];
            }
            else
            {
                $rate->rating = $rating;
                if ($rate->save())
                    $response = [
                        'status' => 200,
                        'message' => $star_rating_module::t('Changed vote')
                    ];
                else
                    $response = [
                        'status' => 400,
                        'message' => $star_rating_module::t('Failed to save')
                    ];
            }
        }
        catch(Exception $exp)
        {
            $response = [
                'status' => 500,
                'message' => $star_rating_module::t('Server problem')
            ];
        }
        return json_encode($response);
    }
452406
def update(postid, userid, rating):
        '''
        
        '''
        rating_recs = TabRating.select().where(
            (TabRating.post_id == postid) & (TabRating.user_id == userid)
        )
        if rating_recs.count() > 0:
            MRating.__update_rating(rating_recs.get().uid, rating)
        else:
            MRating.__insert_data(postid, userid, rating)
287697
public function update() {
        $this->isNewRecord = false;
        if ($this->usesTimestamps()) {
            $this->updateTimestamps();
        }
        $this->invoke(self::BEFORE_UPDATE, [$this]);
        if (!$this->validate()) {
            return false;
        }
        $query = $this->getPrimaryKeyQuery();
        if (empty($query)) {
            $this->setError('pk', 'ERROR PK!');
            return false;
        }
        $data = $this->_getRealFields();
        if (empty($data)) {
            return true;
        }
        $row = $query
            ->update($data);
        if (!empty($row)) {
            $this->setOldAttribute();
        } else {
            $this->setError('data', 'Data is not change!');
        }
        $this->invoke(self::AFTER_UPDATE, [$this]);
        return $row;
    }
424963
public function canRate()
    {
        if ($this->_blRate === null) {
            $this->_blRate = false;
            if ($this->isReviewActive() && ($oActiveRecommList = $this->getActiveRecommList())) {
                $oRating = oxNew(\OxidEsales\Eshop\Application\Model\Rating::class);
                $sUserVariable = \OxidEsales\Eshop\Core\Registry::getSession()->getVariable('usr');
                $this->_blRate = $oRating->allowRating($sUserVariable, 'oxrecommlist', $oActiveRecommList->getId());
            }
        }

        return $this->_blRate;
    }
734481
def update(self):
        
        w = self._weight_generator(self.reviewers)
        diff_p = max(p.update_summary(w) for p in self.products)
        diff_a = max(r.update_anomalous_score() for r in self.reviewers)
        return max(diff_p, diff_a)
1195933
def rating(self, value):
        
        if not self.can_update():
            self._tcex.handle_error(910, [self.type])
        request_data = {'rating': value}
        return self.tc_requests.update(
            self.api_type, self.api_sub_type, self.unique_id, request_data, owner=self.owner
        )
913756
public function data()
    {
        $ratings = RatingTotalModel::with([
            'rateable' => function ($query) {
                $query->with(['ratings', 'ratingTotal'])->select(['id', 'title', 'slug']);
            }])->get();

        $ratings = $ratings->filter(function ($value, $key) {
            return isset($value->rateable);
        });

        $resource = (new RatingTransformer())->transformCollection($ratings);

        return DataTables::of(collect($this->serializeToArray($resource)))
            ->rawColumns(['actions'])
            ->make();
    }