mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2024-12-12 08:36:22 +01:00
Change query to find both albums by artist and album artist
This commit is contained in:
parent
91e597bbdd
commit
37b923bea3
@ -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);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -152,9 +152,8 @@ class CollectionBackend : public CollectionBackendInterface {
|
||||
SongList GetCompilationSongs(const QString &album, const QueryOptions &opt = QueryOptions());
|
||||
|
||||
AlbumList GetAllAlbums(const QueryOptions &opt = QueryOptions());
|
||||
AlbumList GetAlbumsByArtist(const QString &artist, const QueryOptions &opt = QueryOptions());
|
||||
AlbumList GetAlbumsByAlbumArtist(const QString &albumartist, const QueryOptions &opt = QueryOptions());
|
||||
AlbumList GetCompilationAlbums(const QueryOptions &opt = QueryOptions());
|
||||
AlbumList GetAlbumsByArtist(const QString &artist, const QueryOptions &opt = QueryOptions());
|
||||
|
||||
void UpdateManualAlbumArtAsync(const QString &artist, const QString &albumartist, const QString &album, const QString &art);
|
||||
Album GetAlbumArt(const QString &artist, const QString &albumartist, const QString &album);
|
||||
@ -223,6 +222,7 @@ signals:
|
||||
|
||||
void UpdateCompilations(QSqlQuery &find_songs, QSqlQuery &update, SongList &deleted_songs, SongList &added_songs, const QString &album, int compilation_detected);
|
||||
AlbumList GetAlbums(const QString &artist, const QString &album_artist, bool compilation = false, const QueryOptions &opt = QueryOptions());
|
||||
AlbumList GetAlbums(const QString &artist, bool compilation, const QueryOptions &opt = QueryOptions());
|
||||
SubdirectoryList SubdirsInDirectory(int id, QSqlDatabase &db);
|
||||
|
||||
Song GetSongById(int id, QSqlDatabase &db);
|
||||
|
@ -135,6 +135,14 @@ void CollectionQuery::AddWhere(const QString &column, const QVariant &value, con
|
||||
|
||||
}
|
||||
|
||||
void CollectionQuery::AddWhereArtist(const QVariant &value) {
|
||||
|
||||
where_clauses_ << QString("((artist = ? AND albumartist = '') OR albumartist = ?)");
|
||||
bound_values_ << value;
|
||||
bound_values_ << value;
|
||||
|
||||
}
|
||||
|
||||
void CollectionQuery::AddCompilationRequirement(bool compilation) {
|
||||
// The unary + is added to prevent sqlite from using the index idx_comp_artist.
|
||||
// When joining with fts, sqlite 3.8 has a tendency to use this index and thereby nesting the tables in an order which gives very poor performance
|
||||
|
@ -85,6 +85,7 @@ class CollectionQuery {
|
||||
// Adds a fragment of WHERE clause. When executed, this Query will connect all the fragments with AND operator.
|
||||
// Please note that IN operator expects a QStringList as value.
|
||||
void AddWhere(const QString &column, const QVariant &value, const QString &op = "=");
|
||||
void AddWhereArtist(const QVariant &value);
|
||||
|
||||
void AddCompilationRequirement(bool compilation);
|
||||
void SetLimit(int limit) { limit_ = limit; }
|
||||
|
Loading…
Reference in New Issue
Block a user