Skip to content

Commit

Permalink
simplify track regenerate
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlan-00 committed Feb 4, 2024
1 parent 5dd1f72 commit ab2161f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Repository/Model/Playlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,12 @@ public function update_track_number($track_id, $index): void
*/
public function regenerate_track_numbers(): void
{
$items = $this->get_items();
$index = 1;
foreach ($items as $item) {
$this->update_track_number($item['track_id'], $index);
$index = 1;
$sql = 'SELECT `id` FROM `playlist_data` WHERE `playlist_data`.`playlist` = ? ORDER BY `track`, `id`;';
$tracks = Dba::read($sql, array($this->id));

while ($row = Dba::fetch_assoc($tracks)) {
$this->update_track_number($row['id'], $index);
$index++;
}

Expand Down

0 comments on commit ab2161f

Please sign in to comment.