-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from digio-ch/issue/hc-241
Adjust date calculation for "Abteilungen im Vergleich"
- Loading branch information
Showing
6 changed files
with
59 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
src/Service/CensusAPIService.php → src/Service/Census/CensusAPIService.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace App\Service\Census; | ||
|
||
use App\Repository\Midata\CensusGroupRepository; | ||
|
||
class CensusDateProvider | ||
{ | ||
private CensusGroupRepository $censusGroupRepository; | ||
|
||
public function __construct(CensusGroupRepository $censusGroupRepository) | ||
{ | ||
$this->censusGroupRepository = $censusGroupRepository; | ||
} | ||
|
||
/** | ||
* This funciton returns the latest year we have census data for in the database. | ||
* It was created so that census widgets are still usable in the period between the start of a new year until | ||
* the census data is updated. | ||
* @return int | ||
* @throws \Exception | ||
*/ | ||
public function getLatestYear(): int | ||
{ | ||
return $this->censusGroupRepository->getLatestYear(); | ||
} | ||
|
||
public function getRelevantDateRange(): array | ||
{ | ||
return range($this->getLatestYear() - 5, $this->getLatestYear()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters