PartKeepr\StatisticBundle\Services\StatisticService::getUnitCounts PHP Method

getUnitCounts() public method

Returns the part counts per part unit.
public getUnitCounts ( ) : array
return array An array of arrays with the keys "name" and "stockLevel"
    public function getUnitCounts()
    {
        $dql = 'SELECT SUM(p.stockLevel) AS stockLevel, pu AS partMeasurementUnit FROM ';
        $dql .= 'PartKeepr\\PartBundle\\Entity\\PartMeasurementUnit pu LEFT JOIN pu.parts p GROUP BY pu.id';
        return $this->entityManager->createQuery($dql)->getArrayResult();
    }