Smallfix errors

This commit is contained in:
Kalle Fagerberg 2022-07-17 20:00:34 +02:00 committed by thrillfall
parent 33dd043dcb
commit 71e8faf8cd

View File

@ -58,10 +58,7 @@ class PersonalSettingsController extends Controller {
$subStats = array(); $subStats = array();
foreach ($episodeActions as $ep) { foreach ($episodeActions as $ep) {
$url = $ep->getPodcast(); $url = $ep->getPodcast();
$stats = $subStats[$url] ?? [ $stats = $subStats[$url] ?? $this->defaultSubscriptionData();
'listenedSeconds' => 0,
'actionCounts' => $this->defaultActionCounts(),
];
$actionCounts = $stats['actionCounts']; $actionCounts = $stats['actionCounts'];
$actionLower = strtolower($ep->getAction()); $actionLower = strtolower($ep->getAction());
if (array_key_exists($actionLower, $actionCounts)) { if (array_key_exists($actionLower, $actionCounts)) {
@ -79,7 +76,7 @@ class PersonalSettingsController extends Controller {
$subscriptions = array_map(function (SubscriptionChangeEntity $sub) use ($subStats) { $subscriptions = array_map(function (SubscriptionChangeEntity $sub) use ($subStats) {
$url = $sub->getUrl(); $url = $sub->getUrl();
$stats = $subStats[$url] ?? array(); $stats = $subStats[$url] ?? $this->defaultSubscriptionData();
$sub = [ $sub = [
'url' => $url ?? '', 'url' => $url ?? '',
'listenedSeconds' => $stats['listenedSeconds'], 'listenedSeconds' => $stats['listenedSeconds'],
@ -103,13 +100,16 @@ class PersonalSettingsController extends Controller {
]); ]);
} }
private function defaultActionCounts(): array { private function defaultSubscriptionData(): array {
return [ return [
'download' => 0, 'listenedSeconds' => 0,
'delete' => 0, 'actionCounts' => [
'play' => 0, 'download' => 0,
'new' => 0, 'delete' => 0,
'flattr' => 0, 'play' => 0,
'new' => 0,
'flattr' => 0,
],
]; ];
} }
} }