adding parameter until and since on 'work near end'

This commit is contained in:
Julien Fastré 2022-01-23 21:52:16 +01:00
parent 20a4950c60
commit c08bd76e4b

View File

@ -48,8 +48,10 @@ class AccompanyingCourseWorkApiController extends ApiController
*/ */
public function myWorksNearEndDate(Request $request): JsonResponse public function myWorksNearEndDate(Request $request): JsonResponse
{ {
$since = (new \DateTimeImmutable('now'))->sub(new \DateInterval('P15D')); $since = (new \DateTimeImmutable('now'))
$until = (new \DateTimeImmutable('now'))->add(new \DateInterval('P15D')); ->sub(new \DateInterval('P'.$request->query->getInt('since', 15).'D'));
$until = (new \DateTimeImmutable('now'))
->add(new \DateInterval('P'.$request->query->getInt('since', 15).'D'));
$total = $this->accompanyingPeriodWorkRepository $total = $this->accompanyingPeriodWorkRepository
->countNearEndDateByUser($this->getUser(), $since, $until); ->countNearEndDateByUser($this->getUser(), $since, $until);
$paginator = $this->getPaginatorFactory()->create($total); $paginator = $this->getPaginatorFactory()->create($total);