Recalculates ratings for applications

@return string
516847
public function calculateRatingAction()
    {
        $applications = $this->fetchApplications();
        $count = count($applications);
        $i=0;
        echo "Calculate rating for " . $count . " applications ...\n";
        
        $progress = new ProgressBar($count);
        /** @var  \Applications\Entity\Application $application */
        foreach ($applications as $application) {
            $progress->update($i++, 'Application ' . $i . ' / ' . $count);
            $application->getRating(/* recalculate */ true);
        }
        $progress->update($i, 'Write to database...');
        $this->repositories->flush();
        $progress->finish();
        
        return PHP_EOL;
    }
758905
protected function recountRatingOfAllModelTypes()
    {
        $rateableTypes = app(RatingModelContract::class)->select(['rateable_type'])->groupBy('rateable_type')->get();

        foreach ($rateableTypes as $rating) {
            $this->recountRatingOfModelType($rating->rateable_type);
        }
    }
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();
    }
617365
public function getReviews()
    {
        if ($this->_aReviews === null) {
            $this->_aReviews = false;
            if ($this->isReviewActive() && ($oActiveRecommList = $this->getActiveRecommList())) {
                $this->_aReviews = $oActiveRecommList->getReviews();
            }
        }

        return $this->_aReviews;
    }
418741
public function get_value() {
        $this->label = $this->grade->grade_item->itemname;

        $val = $this->grade->finalgrade;
        if ($this->grade->grade_item->scaleid) {
            return $val ? (int)$val : -1;
        } else {
            return $val ? format_float($val, $this->grade->grade_item->get_decimals()) : '';
        }
    }
685670
public function getRatingCount()
    {
        if ($this->_iRatingCnt === null) {
            $this->_iRatingCnt = false;
            if ($this->isReviewActive() && ($oActiveRecommList = $this->getActiveRecommList())) {
                $this->_iRatingCnt = $oActiveRecommList->oxrecommlists__oxratingcnt->value;
            }
        }

        return $this->_iRatingCnt;
    }
579927
public function getRatingValue()
    {
        if ($this->_dRatingValue === null) {
            $this->_dRatingValue = (double) 0;
            if ($this->isReviewActive() && ($oActiveRecommList = $this->getActiveRecommList())) {
                $this->_dRatingValue = round($oActiveRecommList->oxrecommlists__oxrating->value, 1);
            }
        }

        return (double) $this->_dRatingValue;
    }
430307
protected function getListReview()
    {
        $id = $this->getParam(0);

        if (!isset($id)) {
            return $this->review->getList(array('limit' => $this->getLimit()));
        }

        if (!is_numeric($id)) {
            $this->errorAndExit($this->text('Invalid argument'));
        }

        if ($this->getParam('user')) {
            return $this->review->getList(array('user_id' => $id, 'limit' => $this->getLimit()));
        }

        if ($this->getParam('product')) {
            return $this->review->getList(array('product_id' => $id, 'limit' => $this->getLimit()));
        }

        $result = $this->review->get($id);

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        return array($result);
    }
1012750
public function getRatingCount()
    {
        if ($this->_iRatingCnt === null) {
            $this->_iRatingCnt = false;
            if ($this->isReviewActive() && ($oDetailsProduct = $this->getProduct())) {
                $blShowVariantsReviews = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('blShowVariantReviews');
                $this->_iRatingCnt = $oDetailsProduct->getArticleRatingCount($blShowVariantsReviews);
            }
        }

        return $this->_iRatingCnt;
    }
1199886
public function sort()
    {
        $this->sorted = array();
        $hasChanged   = true;
        while (count($this->sorted) < count($this->items) && $hasChanged) {
            $hasChanged = false;
            foreach ($this->dependencies as $item => $deps) {
                if ($this->satisfied($item)) {
                    $this->setSorted($item);
                    $this->removeDependents($item);
                    $hasChanged = true;
                }
                $this->hits[$item]++;
            }
        }

        return $this->sorted;
    }
526080
public function getAverage(ArrayCollection $ratings)
    {
        if ($ratings->count() === 0) {
            $average = 0;
        } else {
            $average = $this->getSum($ratings) / $ratings->count();
        }

        return $average;
    }
164376
public function get_rating($key = 0)
	{
		$ratings = $this->get_ratings();
		if (isset($ratings[$key]))
		{
			return $ratings[$key];
		}

		return null;
	}
702611
public function rewind()
    {
        usort(
            $this->entries, function ($a, $b) {
            return $a['priority'] - $b['priority'];
        }
        );
        $this->position = 0;
        $this->sorted = true;
    }
645925
public function getVersionsBehind()
    {
        $current = $this->getCurrentVersion();
        $versions = array_filter($this->getVersions(),
                function ($version) use ($current) {
                    return $version > $current;
                }
        );

        return count($versions);
    }
321073
def get_real_rating(self):
        """"""
        if not (self.votes and self.score):
            return 0
        return float(self.score)/self.votes
152082
public function getAspectRatio(): float
    {
        $attrs = $this->getXmlAttrs();

        if (!isset($attrs->viewBox)) {
            return 0;
        }

        list(, , $width, $height) = explode(' ', $attrs->viewBox);

        return $width / $height;
    }
1058817
public function getRatingAverage()
    {
        $ratingTotal = $this->ratingTotal;

        $rating = $ratingTotal ? $ratingTotal->rating : 0;
        $rater = $ratingTotal ? $ratingTotal->raters : 0;

        return $rating > 0 ? $rating / $rater : 0;
    }