diff --git a/app/Builders/SongBuilder.php b/app/Builders/SongBuilder.php index c476dd48..298bc860 100644 --- a/app/Builders/SongBuilder.php +++ b/app/Builders/SongBuilder.php @@ -61,7 +61,6 @@ class SongBuilder extends Builder ) ->leftJoin('albums', 'songs.album_id', 'albums.id') ->leftJoin('artists', 'songs.artist_id', 'artists.id') - ->distinct() ->select( 'songs.*', 'albums.name', diff --git a/app/Repositories/AlbumRepository.php b/app/Repositories/AlbumRepository.php index 4f68e2cd..dbafc0fa 100644 --- a/app/Repositories/AlbumRepository.php +++ b/app/Repositories/AlbumRepository.php @@ -44,11 +44,11 @@ class AlbumRepository extends Repository ->join('interactions', static function (JoinClause $join) use ($user): void { $join->on('songs.id', 'interactions.song_id')->where('interactions.user_id', $user->id); }) - ->groupBy('albums.id') + ->groupBy('albums.id', 'play_count') ->distinct() ->orderByDesc('play_count') ->limit($count) - ->get('albums.*'); + ->get(['albums.*', 'play_count']); } /** @return Collection|array */ diff --git a/app/Repositories/ArtistRepository.php b/app/Repositories/ArtistRepository.php index 17fb81a7..1dac0c88 100644 --- a/app/Repositories/ArtistRepository.php +++ b/app/Repositories/ArtistRepository.php @@ -40,7 +40,7 @@ class ArtistRepository extends Repository ->distinct() ->orderByDesc('play_count') ->limit($count) - ->get('artists.*'); + ->get(['artists.*', 'play_count']); } /** @return Collection|array */ diff --git a/app/Repositories/SongRepository.php b/app/Repositories/SongRepository.php index ab308d11..e0a13baa 100644 --- a/app/Repositories/SongRepository.php +++ b/app/Repositories/SongRepository.php @@ -60,6 +60,7 @@ class SongRepository extends Repository return Song::query(user: $scopedUser ?? $this->auth->user()) ->accessible() ->withMeta(requiresInteractions: true) + ->addSelect('interactions.last_played_at') ->orderByDesc('interactions.last_played_at') ->limit($count) ->get(); diff --git a/database/migrations/2024_07_14_180751_convert_json_columns_to_text.php b/database/migrations/2024_07_14_180751_convert_json_columns_to_text.php new file mode 100644 index 00000000..9e3e319b --- /dev/null +++ b/database/migrations/2024_07_14_180751_convert_json_columns_to_text.php @@ -0,0 +1,35 @@ +text('categories')->change(); + $table->text('metadata')->change(); + }); + + Schema::table('queue_states', static function (Blueprint $table): void { + $table->text('song_ids')->change(); + }); + + Schema::table('licenses', static function (Blueprint $table): void { + $table->text('instance')->nullable()->change(); + $table->text('meta')->nullable()->change(); + }); + + Schema::table('songs', static function (Blueprint $table): void { + $table->text('episode_metadata')->nullable()->change(); + }); + + Schema::table('podcast_user', static function (Blueprint $table): void { + $table->text('state')->nullable()->change(); + }); + } +};