Update once-per-X-songs rule.
This commit is contained in:
parent
5f14370a17
commit
ed13d78255
|
@ -9,7 +9,9 @@ There have been no new features in the Rolling Release since the latest Stable r
|
|||
|
||||
## Code Quality/Technical Changes
|
||||
|
||||
There have been no technical changes in the Rolling Release since the latest Stable release.
|
||||
- The scheduler has been updated to follow a new rule for "Once per X Songs" playlists: it will only consider songs
|
||||
played from non-jingle playlists in its calculation. This will prevent other jingles from being counted in the total
|
||||
number of songs played in a time period.
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ class StationQueueRepository extends Repository
|
|||
* This forces the use of indices at the expense of slightly more records being handled.
|
||||
*/
|
||||
$baseQueryBuilder = $this->em->createQueryBuilder()
|
||||
->select('sq.timestamp_played, sq.playlist_id')
|
||||
->select('sq.timestamp_played, sq.is_visible, sq.playlist_id')
|
||||
->from(Entity\StationQueue::class, 'sq')
|
||||
->where('sq.station = :station')
|
||||
->setParameter('station', $station)
|
||||
|
|
|
@ -162,19 +162,29 @@ class Scheduler
|
|||
return false;
|
||||
}
|
||||
|
||||
// Check if already played
|
||||
$relevant_song_history = array_slice($recentPlaylistHistory, 0, $length);
|
||||
$playlistId = $playlist->getIdRequired();
|
||||
|
||||
$was_played = false;
|
||||
foreach ($relevant_song_history as $sh_row) {
|
||||
if ((int)$sh_row['playlist_id'] === $playlist->getId()) {
|
||||
$was_played = true;
|
||||
break;
|
||||
// Only consider playlists that are this playlist or are non-jingles.
|
||||
$relevantSongHistory = array_slice(
|
||||
array_filter(
|
||||
$recentPlaylistHistory,
|
||||
static function ($row) use ($playlistId) {
|
||||
return $playlistId === $row['playlist_id']
|
||||
? true
|
||||
: $row['is_visible'];
|
||||
}
|
||||
),
|
||||
0,
|
||||
$length
|
||||
);
|
||||
|
||||
foreach ($relevantSongHistory as $sh_row) {
|
||||
if ($playlistId === (int)$sh_row['playlist_id']) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
reset($recentPlaylistHistory);
|
||||
return $was_played;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue