Skip to content

Commit

Permalink
VSVGVQ-182 fix typo in TopScoreDoctrineRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
stejes committed Sep 25, 2018
1 parent 83935f8 commit 3a161a7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Statistics/Repositories/TopScoreDoctrineRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function getAverageForCompany(UuidInterface $companyId): Average
public function getTopCompanies(NaturalNumber $nrOfPassedEmployees): ?Companies
{
$companyIdsWithCount = $this->entityManager->createQueryBuilder()
->select('employee.companyId, count(employee.companyId) AS nrOfPastEmployees')
->select('employee.companyId, count(employee.companyId) AS nrOfPassedEmployees')
->from(EmployeeParticipationEntity::class, 'employee')
->innerJoin(TopScoreEntity::class, 'topScore', Join::WITH, 'employee.email = topScore.email')
->groupBy('employee.companyId')
Expand All @@ -133,10 +133,10 @@ public function getTopCompanies(NaturalNumber $nrOfPassedEmployees): ?Companies
->getResult();

$companyIds = [];
$nrOfPastEmployees = [];
$nrOfPassedEmployees = [];
foreach ($companyIdsWithCount as $companyIdWithCount) {
$companyIds[] = $companyIdWithCount['companyId'];
$nrOfPastEmployees[$companyIdWithCount['companyId']] = (int)$companyIdWithCount['nrOfPastEmployees'];
$nrOfPassedEmployees[$companyIdWithCount['companyId']] = (int)$companyIdWithCount['nrOfPassedEmployees'];
}

if (!empty($companyIds)) {
Expand All @@ -153,11 +153,11 @@ public function getTopCompanies(NaturalNumber $nrOfPassedEmployees): ?Companies

return new Companies(
...array_map(
function (CompanyEntity $companyEntity) use ($nrOfPastEmployees) {
function (CompanyEntity $companyEntity) use ($nrOfPassedEmployees) {
$company = $companyEntity->toCompany();
return $company->withNrOfPassedEmployees(
new NaturalNumber(
$nrOfPastEmployees[$company->getId()->toString()]
$nrOfPassedEmployees[$company->getId()->toString()]
)
);
},
Expand Down

0 comments on commit 3a161a7

Please sign in to comment.