Set default since timestamp to 0

This commit is contained in:
Jonathan Flueren 2022-05-23 22:17:05 +02:00 committed by thrillfall
parent 4c4803f117
commit 0d6492e99d
2 changed files with 3 additions and 13 deletions

View File

@ -53,7 +53,7 @@ class EpisodeActionController extends Controller {
* @param int $since
* @return JSONResponse
*/
public function list(int $since): JSONResponse {
public function list(int $since = 0): JSONResponse {
$episodeActions = $this->episodeActionRepository->findAll($since, $this->userId);
$untypedEpisodeActionData = [];

View File

@ -54,8 +54,8 @@ class SubscriptionChangeController extends Controller {
* @param int|null $since
* @return JSONResponse
*/
public function list(int $since = null): JSONResponse {
$sinceDatetime = $this->createDateTimeFromTimestamp($since);
public function list(int $since = 0): JSONResponse {
$sinceDatetime = (new DateTime)->setTimestamp($since);
return new JSONResponse([
"add" => $this->extractUrlList($this->subscriptionChangeRepository->findAllSubscribed($sinceDatetime, $this->userId)),
"remove" => $this->extractUrlList($this->subscriptionChangeRepository->findAllUnSubscribed($sinceDatetime, $this->userId)),
@ -63,16 +63,6 @@ class SubscriptionChangeController extends Controller {
]);
}
/**
* @param int|null $since
* @return DateTime
*/
private function createDateTimeFromTimestamp(?int $since): DateTime {
return ($since !== null)
? (new DateTime)->setTimestamp($since)
: (new DateTime('-1 week'));
}
/**
* @param array $allSubscribed
* @return mixed