Change query to find both albums by artist and album artist

This commit is contained in:
Jonas Kvinge
2019-04-18 00:45:32 +02:00
parent 91e597bbdd
commit 37b923bea3
4 changed files with 19 additions and 18 deletions

View File

@@ -567,12 +567,11 @@ QStringList CollectionBackend::GetAllArtistsWithAlbums(const QueryOptions &opt)
// Albums with 'albumartist' field set:
CollectionQuery query(opt);
// query.SetColumnSpec("DISTINCT artist");
query.SetColumnSpec("DISTINCT albumartist");
query.AddCompilationRequirement(false);
query.AddWhere("album", "", "!=");
// Albums with no 'albumartist' (extract 'artist'):
// Albums with no 'albumartist' (extract 'artist'):
CollectionQuery query2(opt);
query2.SetColumnSpec("DISTINCT artist");
query2.AddCompilationRequirement(false);
@@ -600,15 +599,11 @@ QStringList CollectionBackend::GetAllArtistsWithAlbums(const QueryOptions &opt)
}
CollectionBackend::AlbumList CollectionBackend::GetAllAlbums(const QueryOptions &opt) {
return GetAlbums(QString(), QString(), false, opt);
return GetAlbums(QString(), false, opt);
}
CollectionBackend::AlbumList CollectionBackend::GetAlbumsByArtist(const QString &artist, const QueryOptions &opt) {
return GetAlbums(artist, QString(), false, opt);
}
CollectionBackend::AlbumList CollectionBackend::GetAlbumsByAlbumArtist(const QString &album_artist, const QueryOptions &opt) {
return GetAlbums(QString(), album_artist, false, opt);
return GetAlbums(artist, false, opt);
}
SongList CollectionBackend::GetSongsByAlbum(const QString &album, const QueryOptions &opt) {
@@ -750,7 +745,7 @@ SongList CollectionBackend::GetSongsByUrl(const QUrl &url) {
}
CollectionBackend::AlbumList CollectionBackend::GetCompilationAlbums(const QueryOptions &opt) {
return GetAlbums(QString(), QString(), true, opt);
return GetAlbums(QString(), true, opt);
}
SongList CollectionBackend::GetCompilationSongs(const QString &album, const QueryOptions &opt) {
@@ -861,9 +856,10 @@ void CollectionBackend::UpdateCompilations(QSqlQuery &find_songs, QSqlQuery &upd
update.bindValue(":album", album);
update.exec();
db_->CheckErrors(update);
}
CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist, const QString &album_artist, bool compilation, const QueryOptions &opt) {
CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist, bool compilation, const QueryOptions &opt) {
AlbumList ret;
@@ -874,13 +870,9 @@ CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist,
if (compilation) {
query.AddCompilationRequirement(true);
}
else if (!album_artist.isNull() && !album_artist.isEmpty()) {
else if (!artist.isEmpty()) {
query.AddCompilationRequirement(false);
query.AddWhere("albumartist", album_artist);
}
else if (!artist.isNull() && !artist.isEmpty()) {
query.AddCompilationRequirement(false);
query.AddWhere("artist", artist);
query.AddWhereArtist(artist);
}
{