diff --git a/src/Entity/Repository/SongHistoryRepository.php b/src/Entity/Repository/SongHistoryRepository.php index 80b3b2754..804735761 100644 --- a/src/Entity/Repository/SongHistoryRepository.php +++ b/src/Entity/Repository/SongHistoryRepository.php @@ -114,6 +114,7 @@ final class SongHistoryRepository extends AbstractStationBasedRepository $this->em->persist($previousCurrentSong); } + $newCurrentSong->setListenersFromLastSong($previousCurrentSong); $newCurrentSong->setTimestampStart(time()); $newCurrentSong->updateVisibility(); diff --git a/src/Entity/SongHistory.php b/src/Entity/SongHistory.php index a9d4b4a41..81ab641a0 100644 --- a/src/Entity/SongHistory.php +++ b/src/Entity/SongHistory.php @@ -275,6 +275,19 @@ class SongHistory implements $this->delta_points = $delta_points; } + public function setListenersFromLastSong(?SongHistory $lastSong): void + { + if (null === $lastSong) { + $this->addDeltaPoint(0); + return; + } + + $deltaPoints = (array)$lastSong->getDeltaPoints(); + $lastDeltaPoint = array_pop($deltaPoints); + + $this->addDeltaPoint($lastDeltaPoint); + } + public function getIsVisible(): bool { return $this->is_visible; diff --git a/src/Radio/AutoDJ/Annotations.php b/src/Radio/AutoDJ/Annotations.php index be6109306..bdf10189c 100644 --- a/src/Radio/AutoDJ/Annotations.php +++ b/src/Radio/AutoDJ/Annotations.php @@ -146,14 +146,14 @@ final class Annotations implements EventSubscriberInterface return; } + $event->addAnnotations([ + 'playlist_id' => $playlist->getId(), + ]); + if ($playlist->getIsJingle()) { $event->addAnnotations([ 'jingle_mode' => 'true', ]); - } else { - $event->addAnnotations([ - 'playlist_id' => $playlist->getId(), - ]); } }