mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
fix: issues with DISTINCT on pgsql (#1789)
This commit is contained in:
parent
702913a76c
commit
3b34819706
5 changed files with 39 additions and 4 deletions
|
@ -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',
|
||||
|
|
|
@ -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<array-key, Album> */
|
||||
|
|
|
@ -40,7 +40,7 @@ class ArtistRepository extends Repository
|
|||
->distinct()
|
||||
->orderByDesc('play_count')
|
||||
->limit($count)
|
||||
->get('artists.*');
|
||||
->get(['artists.*', 'play_count']);
|
||||
}
|
||||
|
||||
/** @return Collection|array<array-key, Artist> */
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('podcasts', static function (Blueprint $table): void {
|
||||
$table->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();
|
||||
});
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue