Skip to content

Commit

Permalink
Reuse getVacationsProjectId() inside getVacationsDates().
Browse files Browse the repository at this point in the history
We simplify our code and remove one use of the VACATIONS_PROJECT
config parameter, which we may want to get rid of later.
  • Loading branch information
jaragunde committed Mar 30, 2022
1 parent 650b8ef commit aa29fc5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 3 additions & 1 deletion model/dao/TaskDAO/PostgreSQLTaskDAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,10 @@ public function getVacations(UserVO $userVO, DateTime $initDate = NULL, DateTime

}

public function getVacationsDates(UserVO $userVO, int $projectId = NULL, DateTime $initDate = NULL, DateTime $endDate = NULL): array
public function getVacationsDates(UserVO $userVO, DateTime $initDate = NULL, DateTime $endDate = NULL): array
{
$projectId = $this->getVacationsProjectId();

if (is_null($projectId)) {
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion model/dao/TaskDAO/TaskDAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public abstract function getProjectUserWeeklyWorkingHours(ProjectVO $project, Da
*/
public abstract function getVacations(UserVO $userVO, DateTime $initDate = NULL, DateTime $endDate = NULL);

public abstract function getVacationsDates(UserVO $userVO, int $projectId = NULL, DateTime $initDate = NULL, DateTime $endDate = NULL): array;
public abstract function getVacationsDates(UserVO $userVO, DateTime $initDate = NULL, DateTime $endDate = NULL): array;

/** Task partial updater for PostgreSQL.
*
Expand Down
5 changes: 1 addition & 4 deletions model/facade/action/GetScheduledHolidaysAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ protected function doExecute(): array

$taskDao = DAOFactory::getTaskDAO();
$userDao = DAOFactory::getUserDAO();
$projectDao = DAOFactory::getProjectDAO();

if (is_null($this->user)) {
return [];
Expand All @@ -58,12 +57,10 @@ protected function doExecute(): array
} else
if (is_null($this->user->getId()))
$this->user = $userDao->getByUserLogin($this->user->getLogin());

$projectId = $projectDao->getByDescription(ConfigurationParametersManager::getParameter('VACATIONS_PROJECT'));
$reportInit = $this->init;
$reportEnd = $this->end;

$vacations = $taskDao->getVacationsDates($this->user, $projectId, $reportInit, $reportEnd);
$vacations = $taskDao->getVacationsDates($this->user, $reportInit, $reportEnd);

return $vacations;
}
Expand Down

0 comments on commit aa29fc5

Please sign in to comment.