Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Commit

Permalink
Fixing the query for counting the varieties on dashboard.
Browse files Browse the repository at this point in the history
It's related to PR #51.
  • Loading branch information
bepitulaz committed Oct 23, 2017
1 parent b4a8c58 commit 918fa49
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/AppBundle/Repository/PlantRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ public function countByFarm($farmId)
{
$qb = $this->getRepository()->createQueryBuilder('p');

$qb->select('COUNT (p) AS total_crops')
$qb->select('p')
->innerJoin('AppBundle:Seed', 's', 'WITH', 'p.seed = s.id')
->innerJoin('AppBundle:Area', 'a', 'WITH', 'p.area = a.id')
->where('a.field = '.$farmId)
->groupBy('p.seed')
->getQuery();

$query = $qb->getQuery()->getOneOrNullResult();

return (int) $query['total_crops'];
$query = $qb->getQuery()->getResult();

return (int) count($query);
}

/**
Expand Down

0 comments on commit 918fa49

Please sign in to comment.