#2689 -- Modify how playlist "played()" times are tracked for queueing.

This commit is contained in:
Buster "Silver Eagle" Neece 2020-04-16 18:57:27 -05:00
parent e82212629a
commit 2d5ea6db6a
No known key found for this signature in database
GPG Key ID: 6D9E12FF03411F4E
2 changed files with 6 additions and 12 deletions

View File

@ -453,11 +453,6 @@ class StationPlaylist
$this->played_at = $played_at;
}
public function played(): void
{
$this->played_at = time();
}
public function getQueue(): ?array
{
return $this->queue;

View File

@ -111,13 +111,6 @@ class AutoDJ implements EventSubscriberInterface
$sh->sentToAutodj();
$this->em->persist($sh);
// Mark the playlist itself as played at this time.
$playlist = $sh->getPlaylist();
if ($playlist instanceof Entity\StationPlaylist) {
$playlist->played();
$this->em->persist($playlist);
}
// The "get next song" function is only called when a streamer is not live
$this->streamerRepo->onDisconnect($event->getStation());
$this->em->flush();
@ -363,6 +356,9 @@ class AutoDJ implements EventSubscriberInterface
$media_to_play = $this->getQueuedSong($playlist, $recentSongHistory, $preferredMode);
if ($media_to_play instanceof Entity\StationMedia) {
$playlist->setPlayedAt($now->getTimestamp());
$this->em->persist($playlist);
$spm = $media_to_play->getItemForPlaylist($playlist);
$spm->played($now->getTimestamp());
@ -383,6 +379,9 @@ class AutoDJ implements EventSubscriberInterface
if (is_array($media_to_play)) {
[$media_uri, $media_duration] = $media_to_play;
$playlist->setPlayedAt($now->getTimestamp());
$this->em->persist($playlist);
$sh = new Entity\SongHistory($this->songRepo->getOrCreate([
'text' => 'Remote Playlist URL',
]), $playlist->getStation());